Nodejs HTML Escape escape_html()

Here you can find the source of escape_html()

Method Source Code

String.prototype.escape_html = function() {
    return this.replace(/&/g, "&")
               .replace(/</g, "&lt;")
               .replace(/>/g, "&gt;")
               .replace(/"/g, "&quot;");
}

Related

  1. escapeHTML()
    var __entityMap = {
      "&": "&amp;",
      "<": "&lt;",
      ">": "&gt;",
      '"': '&quot;',
      "'": '&#39;',
      "/": '&#x2F;'
    };
    String.prototype.escapeHTML = function() {
    ...
    
  2. escapeHTML()
    String.prototype.escapeHTML = function () {
        return ('' + this).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;');
    }; 
    
  3. escapeHtml()
    String.prototype.escapeHtml = function() {
            return this
              .replace(/&/g, '&amp;')
                .replace(/"/g,  '&quot;')
                  .replace(/'/g,  '&#039;')
                    .replace(/</g,  '&lt;')
                      .replace(/>/g,  '&gt;');
    };
    
  4. escapeHtml()
    var entityMap = {
        '&': '&amp;',
        '<': '&lt;',
        '>': '&gt;',
        '"': '&quot;',
        "'": '&#39;',
        '/': '&#x2F;'
    };
    String.prototype.escapeHtml = function() {
    ...
    
  5. escapeHtml()
    String.prototype.escapeHtml = String.prototype.escapeHtml || (String.prototype.escapeHtml = function() {
      return this.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
    });
    
  6. escape_html()
    String.prototype.escape_html = function(){
      var span = document.createElement('span');
      var txt =  document.createTextNode('');
      span.appendChild(txt);
      txt.data = this;
      return span.innerHTML;
    };
    
  7. escape_html()
    String.prototype.escape_html = function(){
      var span = document.createElement('span');
      var txt =  document.createTextNode('');
      span.appendChild(txt);
      txt.data = this;
      return span.innerHTML;
    };
    var Notifer = new function(){
      var self = this;
    ...
    
  8. escapelHTML()
    String.prototype.escapelHTML = function(){
        return String(this)
            .replace(/&/g, "&amp;")
            .replace(/</g, "&lt;")
            .replace(/>/g, "&gt;")
            .replace(/"/g, "&quot;")
            .replace(/'/g, "&#039;")
            .replace(/\
    };
    ...
    
  9. htmlEscape()
    String.prototype.htmlEscape = function(){
        var span = document.createElement('span');
        var txt =  document.createTextNode('');
        span.appendChild(txt);
        txt.data = this;
        return span.innerHTML;
    };