|
9 | 9 | */
|
10 | 10 |
|
11 | 11 | ( function() {
|
| 12 | + |
12 | 13 | var functions = [],
|
13 | 14 | cssVendorPrefix =
|
14 | 15 | CKEDITOR.env.gecko ? '-moz-' :
|
15 | 16 | CKEDITOR.env.webkit ? '-webkit-' :
|
16 | 17 | CKEDITOR.env.ie ? '-ms-' :
|
17 |
| - ''; |
| 18 | + '', |
| 19 | + _ampRegex= /&/g, |
| 20 | + _gtRegex= />/g, |
| 21 | + _ltRegex= /</g, |
| 22 | + _quoteRegex= /"/g, |
| 23 | + |
| 24 | + _ampEscRegex= /&/g, |
| 25 | + _gtEscRegex= />/g, |
| 26 | + _ltEscRegex= /</g, |
| 27 | + _quoteEscRegex= /"/g; |
18 | 28 |
|
19 | 29 | CKEDITOR.on( 'reset', function() {
|
20 | 30 | functions = [];
|
|
321 | 331 | * @returns {String} The encoded string.
|
322 | 332 | */
|
323 | 333 | htmlEncode: function( text ) {
|
324 |
| - return String( text ).replace( /&/g, '&' ).replace( />/g, '>' ).replace( /</g, '<' ); |
| 334 | + return String( text ).replace( _ampRegex, '&' ).replace( _gtRegex, '>' ).replace( _ltRegex, '<' ); |
325 | 335 | },
|
326 | 336 |
|
327 | 337 | /**
|
|
333 | 343 | * @returns {String} The decoded string.
|
334 | 344 | */
|
335 | 345 | htmlDecode: function( text ) {
|
336 |
| - return text.replace( /&/g, '&' ).replace( />/g, '>' ).replace( /</g, '<' ); |
| 346 | + return text.replace( _ampEscRegex, '&' ).replace( _gtEscRegex, '>' ).replace( _ltEscRegex, '<' ); |
337 | 347 | },
|
338 | 348 |
|
339 | 349 | /**
|
|
345 | 355 | * @returns {String} The encoded value.
|
346 | 356 | */
|
347 | 357 | htmlEncodeAttr: function( text ) {
|
348 |
| - return text.replace( /"/g, '"' ).replace( /</g, '<' ).replace( />/g, '>' ); |
| 358 | + return text.replace( _quoteRegex, '"' ).replace( _ltRegex, '<' ).replace( _gtRegex, '>' ); |
349 | 359 | },
|
350 | 360 |
|
351 | 361 | /**
|
|
359 | 369 | * @returns {String} The decoded text.
|
360 | 370 | */
|
361 | 371 | htmlDecodeAttr: function( text ) {
|
362 |
| - return text.replace( /"/g, '"' ).replace( /</g, '<' ).replace( />/g, '>' ); |
| 372 | + return text.replace( _quoteEscRegex, '"' ).replace( _ltEscRegex, '<' ).replace( _gtEscRegex, '>' ); |
363 | 373 | },
|
364 | 374 |
|
365 | 375 | /**
|
|
0 commit comments