Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8851: Fix_leak_and_unescapeHTML_order.patch

File Fix_leak_and_unescapeHTML_order.patch, 1.5 kB (added by jdalton, 1 year ago)

Fixes the memory leak and the unescapeHTML order for IE and WebKit

  • string.js

    old new  
    202202  } 
    203203}); 
    204204 
    205 if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { 
    206   escapeHTML: function() { 
    207     return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); 
    208   }, 
    209   unescapeHTML: function() { 
    210     return this.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>'); 
    211   } 
    212 }); 
     205if (Prototype.Browser.WebKit || Prototype.Browser.IE) { 
     206  Object.extend(String.prototype, { 
     207    escapeHTML: function() { 
     208      return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); 
     209    }, 
     210    unescapeHTML: function() { 
     211      return this.replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&'); 
     212    } 
     213  }); 
     214} else { 
     215  Object.extend(String.prototype.escapeHTML, { 
     216    div:  document.createElement('div'), 
     217    text: document.createTextNode('') 
     218  }); 
     219   
     220  with (String.prototype.escapeHTML) div.appendChild(text); 
     221
    213222 
    214223String.prototype.gsub.prepareReplacement = function(replacement) { 
    215224  if (typeof replacement == 'function') return replacement; 
     
    219228 
    220229String.prototype.parseQuery = String.prototype.toQueryParams; 
    221230 
    222 Object.extend(String.prototype.escapeHTML, { 
    223   div:  document.createElement('div'), 
    224   text: document.createTextNode('') 
    225 }); 
    226  
    227 with (String.prototype.escapeHTML) div.appendChild(text); 
    228  
    229231var Template = Class.create(); 
    230232Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; 
    231233Template.prototype = {