Opened 11 years ago

Closed 11 years ago

#893 closed defect (fixed)

GetHtml: config.only7BitPrintablesInURLs not working properly

Reported by: ray Owned by: wymsy
Priority: normal Milestone: Version 1.0
Component: Plugin_GetHtml Version: trunk
Severity: normal Keywords:
Cc:

Description

In Mozilla the encoding is incorrect, in IE it doesn't work at all
see the comments for details

Index: get-html.js
===================================================================
--- get-html.js	(revision 601)
+++ get-html.js	(working copy)
@@ -80,8 +80,15 @@
 	if(HTMLArea.is_ie && c[13].test(sHtml)) {
 		sHtml = sHtml.replace(c[13],'$1'+this.stripBaseURL(RegExp.$3)+'"');
 	}
-	if(this.config.only7BitPrintablesInURLs && c[13].test(sHtml)) {
-	  sHtml = sHtml.replace(c[13], '$1'+RegExp.$3.replace(/([^!-~]+)/g,function(chr){return escape(chr);})+'"');
+	if(this.config.only7BitPrintablesInURLs) {
+		if (HTMLArea.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
+		if ( c[13].test(sHtml)) {
+			try { //Mozilla returns an incorrectly encoded value with innerHTML
+				sHtml = sHtml.replace(c[13], '$1'+decodeURIComponent(RegExp.$3).replace(/([^!-~]+)/g,function(chr){return escape(chr);})+'"');
+			} catch (e) { // once the URL is escape()ed, you can't decodeURIComponent() it anymore
+				sHtml = sHtml.replace(c[13], '$1'+RegExp.$3.replace(/([^!-~]+)/g,function(chr){return escape(chr);})+'"');
+			}
+		}
 	}
 	return sHtml;
 };

Change History (2)

comment:1 Changed 11 years ago by ray

  • Milestone set to Version 1.0
  • Version set to trunk

Committed rev [623]

comment:2 Changed 11 years ago by ray

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.