Opened 9 years ago

Closed 9 years ago

#57 closed defect (fixed)

Patch: Charset, utf-8 encoding for _postback

Reported by: ns@… Owned by: gogo
Priority: normal Milestone:
Component: Xinha Core Version:
Severity: normal Keywords: patch charset utf8 utf-8
Cc:

Description

--- htmlarea.js (Revision 38)
+++ htmlarea.js (Arbeitskopie)
@@ -241,6 +241,16 @@
   if (this.baseURL && this.baseURL.match(/(.*)\/([^\/]+)/))
     this.baseURL = RegExp.$1 + "/";

+  // CharSet of the iframe, default is the charset of the document
+  if (HTMLArea.is_gecko)
+  {
+    this.charSet = document.characterSet;
+  }
+  else
+  {
+    this.charSet = document.charset;
+  }
+
   // URL-s
   this.imgURL = "images/";
   this.popupURL = "popups/";
@@ -1413,9 +1423,10 @@
       doc.open();
       var html = "<html>\n";
       html += "<head>\n";
-      if(typeof editor.config.baseHref != 'undefined')
+      html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + editor.config.charSet + "\">\n";
+      if(typeof editor.config.baseHref != 'undefined' && editor.config.baseHref != null)
       {
-        html += "<base href=\"" + editor.config.baseHref + "\"/>";
+        html += "<base href=\"" + editor.config.baseHref + "\"/>\n";
       }
       html += "<style title=\"table borders\">"
            + ".htmtableborders, .htmtableborders td, .htmtableborders th {border : 1px dashed lightgrey ! important;} \n"
@@ -4337,7 +4348,7 @@
   var content = '';
   for(var i in data)
   {
-    content += (content.length ? '&' : '') + i + '=' + escape(data[i]);
+    content += (content.length ? '&' : '') + i + '=' + encodeURIComponent(data[i]);
   }

   function callBack()

and i think the charset=utf-8 can be removed here too - as only ASCII-chars will be posted (all others are esacped as %xx%xx)

@@ -4362,7 +4373,7 @@
   req.setRequestHeader
   (
       'Content-Type',
-      'application/x-www-form-urlencoded; charset=UTF-8'
+      'application/x-www-form-urlencoded'
   );
   //alert(content);
   req.send(content);

Attachments (1)

.2 (0 bytes) - added by anonymous 9 years ago.

Download all attachments as: .zip

Change History (2)

comment:1 Changed 9 years ago by gogo

  • Resolution set to fixed
  • Status changed from new to closed

Applied in changeset:39 , except for the UTF-8 change, see the commit log for why.

Changed 9 years ago by anonymous

Note: See TracTickets for help on using tickets.