[Webkit-unassigned] [Bug 6452] KIO::appendEscapingBadChars() doesn't know about %u-escaping.

bugzilla-daemon at opendarwin.org bugzilla-daemon at opendarwin.org
Tue Jan 10 05:47:27 PST 2006


http://bugzilla.opendarwin.org/show_bug.cgi?id=6452





------- Additional Comments From grubba at grubba.org  2006-01-10 05:47 -------
I've verified that my javascript code works as expected in Firefox 1.5.

It's hard to do a portable test case, since the typical use is in AJAX code, but
here's an extract:

index.js:

var isSafari = navigator.appVersion.match("AppleWebKit");

    function xmlhttpRequest(filepath, callback)
    {
      var xmlhttp;
      if(window.XMLHttpRequest)
      { // Mozilla, Safari, ...
        xmlhttp = new XMLHttpRequest();
      }
      else if (window.ActiveXObject)
      { // IE
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      
      xmlhttp.open("GET", filepath, true);
      xmlhttp.onreadystatechange = function()
      {
        var value = callback(xmlhttp);
	return value;
      };
      xmlhttp.send(null)
    }

    function getResponseXML(xmlhttp)
    {
      var doc = document.importNode(xmlhttp.responseXML.documentElement, true);
      
      if(isSafari)
      {
        // Safari doesn't initialise all node attributes (name, class etc.)
	// properly without this workaround.
        doc.innerHTML = doc.innerHTML;
      }

      return doc;
    }

    function editGetFields(tag_list, data)
    {
      for(var i = 0; i < tag_list.length; i++)
      {
        var name = tag_list.item(i).getAttribute("name");
        if(name)
	{
	  data[name] = tag_list.item(i).value;
	}
      }
    }
       
    function editTextSave(button, close)
    {
      var div_edit = document.getElementById("document-editor");
      var document_id = div_edit.getAttribute("name");

      var article_id = getArticleId(div_edit);
      var article_tr = document.getElementById("article-open-" + article_id);
    
      var data = new Object;
      editGetFields(div_edit.getElementsByTagName("input"), data);
      editGetFields(div_edit.getElementsByTagName("textarea"), data);

      var callback = function(xmlhttp)
      {
        if(xmlhttp.readyState != 4)
	  return;

	var table_db = getResponseXML(xmlhttp);
	var tr_db = table_db.getElementsByTagName("tr").item(0);
	  
	article_tr.parentNode.replaceChild(tr_db, article_tr);
	  
	if(close)
	{
	  displayArticleList();
	}
      }

      xmlhttpRequest("actions/edit-text-save.xml?" +
                     "article_id="+escape(article_id) + "&" +
                     "document_id="+escape(document_id) + "&" +
		     "finished="+escape(data.finished) + "&" +
		     "headline="+escape(data.headline) + "&" +
		     "subheadline="+escape(data.subheadline) + "&" +
		     "keywords="+escape(data.keywords) + "&" +
		     "blurb="+escape(data.blurb) + "&" +
		     "byline="+escape(data.byline) + "&" +
		     "notes="+escape(data.notes) + "&" +
		     "story="+escape(data.story),
		     callback);
		     
      return false;
    }

If one of data.x contains a unicode character outside ISO-8859-1 (like eg \u2014
(EM_DASH)), escape() above will encode it with %u-style encoding (eg %u2014).
This is as expected. However when the resulting request is received by the http
server the DWIM in XMLHttpRequest::open() will have quoted it an extra time (to
eg %25u2014) when sent by Safari:

ceylon.roxen.com - - [09/Jan/2006:17:15:44 +0100] "GET /es/actions/edit-text-sav
e.xml?article_id=441&document_id=324&finished=on&headline=Katastrofhj%E4lp%20_%2
0ny%20exportsatsning&subheadline=&keywords=&blurb=&byline=&notes=&story=%E5%E4%F
6%20%25uACA1%25uAC94%25uAC84%0A%0AKatastrofhj%E4lp%20%25u2014%20ny%20exportsatsn
ing%20%E5%E4%F6%20%BFSpanska%20fr%E5gor%3F%2075%20%25u2031%20%25u260E%0A%0AStora
%20katastrofer%20skapar%20lidande%20och%20n%F6d%20%25u2014%20men%20ocks%E5%20exp
[...]

Note that there are several cases of double-escaped unicode characters above.

But not with Firefox:

shipon.roxen.com - - [09/Jan/2006:16:23:33 +0100] "GET /es/actions/edit-text-sav
e.xml?article_id=441&document_id=324&finished=on&headline=Katastrofhj%E4lp%20_%2
0ny%20exportsatsning&subheadline=&keywords=&blurb=&byline=&notes=&story=%u6CE8%u
6587%u65B9%u6CD5%u304C%u3072%u3068%u76EE%u3067%u308F%u304B%u308B%u30AC%u30A4%u30
C9%u30C4%u30A2%u30FC%u306F%u3053%u3061%u3089%u3002%0A%u260E%20%E5%E4%F6%2075%20%
[...]

Above unicode characters have been escaped a single time (as expected).

-- 
Configure bugmail: http://bugzilla.opendarwin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list