http://www.mediawiki.org/wiki/Special:Code/MediaWiki/91990

Revision: 91990
Author:   tparscal
Date:     2011-07-12 19:48:00 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Switched to using lookup table for HTML encoding.

Modified Paths:
--------------
    trunk/parsers/wikidom/lib/es/es.Content.js

Modified: trunk/parsers/wikidom/lib/es/es.Content.js
===================================================================
--- trunk/parsers/wikidom/lib/es/es.Content.js  2011-07-12 19:38:38 UTC (rev 
91989)
+++ trunk/parsers/wikidom/lib/es/es.Content.js  2011-07-12 19:48:00 UTC (rev 
91990)
@@ -160,6 +160,17 @@
        return out;
 };
 
+Content.htmlCharacters = {
+       '&': '&',
+       '<': '&lt;',
+       '>': '&gt;',
+       '\'': '&#039;',
+       '"': '&quot;',
+       ' ': '&nbsp;',
+       '\n': '<span class="editSurface-whitespace">&#182;</span>',
+       '\t': '<span class="editSurface-whitespace">&#8702;</span>'
+};
+
 Content.prototype.render = function( start, end ) {
        if ( start || end ) {
                return this.slice( start, end ).render();
@@ -197,19 +208,7 @@
                                }
                        }
                }
-               out += right[0]
-                       // Tags
-                       .replace( /&/g, '&amp;' )
-                       .replace( /</g, '&lt;' )
-                       .replace( />/g, '&gt;' )
-                       // Quotes - probably not needed
-                       //.replace( /'/g, '&#039;' )
-                       //.replace( /"/g, '&quot;' )
-                       // Whitespace
-                       .replace( / /g, '&nbsp;' )
-                       .replace( /\n/g, '<span 
class="editSurface-whitespace">\\n</span>' )
-                       .replace( /\t/g, '<span 
class="editSurface-whitespace">\\t</span>' );
-               
+               out += right[0] in Content.htmlCharacters ? 
Content.htmlCharacters[right[0]] : right[0];
                left = right;           
        }
        


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to