Changeset 1129
- Timestamp:
- 11/22/08 00:07:55 (5 years ago)
- Files:
-
- 1 modified
-
trunk/modules/GetHtml/TransformInnerHTML.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/GetHtml/TransformInnerHTML.js
r1034 r1129 65 65 } 66 66 } 67 67 68 /** 68 69 * Cleans HTML into wellformed xhtml … … 86 87 replace(c[10], ' ');//trim extra whitespace 87 88 if(Xinha.is_ie && c[13].test(sHtml)) { 88 sHtml = sHtml.replace(c[13],'$1'+this.stripBaseURL(RegExp.$3)+'"'); 89 } 89 sHtml = sHtml.replace(c[13],'$1'+Xinha._escapeDollars(stripBaseURL(RegExp.$3))+'"'); 90 } 91 90 92 if(this.config.only7BitPrintablesInURLs) { 91 93 if (Xinha.is_ie) c[13].test(sHtml); // oddly the test below only triggers when we call this once before (IE6), in Moz it fails if tested twice 92 94 if ( c[13].test(sHtml)) { 93 95 try { //Mozilla returns an incorrectly encoded value with innerHTML 94 sHtml = sHtml.replace(c[13], '$1'+decodeURIComponent(RegExp.$3).replace(/([^!-~]+)/g,function(chr){return escape(chr);})+'"'); 96 sHtml = sHtml.replace(c[13], '$1'+Xinha._escapeDollars(decodeURIComponent(RegExp.$3).replace(/([^!-~]+)/g, function(chr) 97 {return escape(chr);}))+'"'); 95 98 } catch (e) { // once the URL is escape()ed, you can't decodeURIComponent() it anymore 96 sHtml = sHtml.replace(c[13], '$1'+RegExp.$3.replace(/([^!-~]+)/g,function(chr){return escape(chr);})+'"');99 sHtml = sHtml.replace(c[13], Xinha._escapeDollars('$1'+RegExp.$3.replace(/([^!-~]+)/g,function(chr){return escape(chr);})+'"')); 97 100 } 98 101 } … … 216 219 return html; 217 220 }; 221 222 /** 223 * Escapes dollar signs ($) to make them safe to use in regex replacement functions by replacing each $ in the input with $$. 224 * 225 * This is advisable any time the replacement string for a call to replace() is a variable and could contain dollar signs that should not be interpreted as references to captured groups (e.g., when you want the text "$10" and not the first captured group followed by a 0). 226 * See http://trac.xinha.org/ticket/1337 227 */ 228 Xinha._escapeDollars = function(str) { 229 return str.replace(/\$/g, "$$$$"); 230 };
