1 // !code vendor/crayon/lib/crayon.js 2 /** 3 * @class 4 * @namespace Provides escaping utilities. 5 * @requires crayon/lib/crayon.js 6 */ 7 Crayon.Escape = { 8 /** 9 * Escapes html special charactors. 10 */ 11 html_escape : function(s){ 12 return s.toString().replace(/&/g, "&") 13 .replace(/\"/g, """) 14 .replace(/\'/g, "'") 15 .replace(/</g, "<") 16 .replace(/>/g, ">"); 17 }, 18 19 /** 20 * Escapes json special charactors. 21 */ 22 json_escape : function(s){ 23 return s.toString().replace(/&/g, "\u0026") 24 .replace(/</g, "\u003C") 25 .replace(/>/g, "\u003E"); 26 } 27 }; 28 29 /** 30 * @function 31 * @description 32 * alias for html_escape 33 */ 34 Crayon.Escape.h = Crayon.Escape.html_escape; 35 /** 36 * @function 37 * @description 38 * alias for json_escape 39 */ 40 Crayon.Escape.j = Crayon.Escape.json_escape; 41 42 if( !this.do_not_import_global ){ 43 Crayon.extend(this, Crayon.Escape); 44 }else{ 45 Crayon.extend(Crayon.Escape); 46 } 47