<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>131242</bug_id>
          
          <creation_ts>2006-07-23 16:24:01 +0000</creation_ts>
          <short_desc>xmlhttprequest breaks on utf-8 strings</short_desc>
          <delta_ts>2006-08-24 16:19:52 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>konqueror</product>
          <component>kjs</component>
          <version>unspecified</version>
          <rep_platform>unspecified</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Rob Kaper">webmaster</reporter>
          <assigned_to name="Konqueror Bugs">konqueror-bugs-null</assigned_to>
          
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>20</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>455331</commentid>
    <comment_count>0</comment_count>
    <who name="Rob Kaper">webmaster</who>
    <bug_when>2006-07-23 16:24:01 +0000</bug_when>
    <thetext>Version:           3.5.3 (using KDE 3.5.3, compiled sources)
Compiler:          gcc version 3.4.6
OS:                Linux (i686) release 2.4.31

Might be related to #130234, not sure.

XmlHttpRequests containing UTF-8 POST data are not sent correctly. A simple testcase is available here:

http://www.robertjohnkaper.com/tmp/kio_utf8.html

Works fine in Firefox, but Konqueror messes up and loses input data.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>456579</commentid>
    <comment_count>1</comment_count>
    <who name="Jan Mentzel">jan_mentzel</who>
    <bug_when>2006-07-29 16:00:46 +0000</bug_when>
    <thetext>Version:   3.5.3 (using KDE 3.5.3)
Compiler:  gcc (GCC) 3.4.5 (Gentoo 3.4.5, ssp-3.4.5-1.0, pie-8.7.9)
OS:        Linux i686 2.6.17-ck1-r2 #1 PREEMPT

Same problem here with german &quot;Umlaute&quot;.

Seems to me as there runs something wrong when konqueror calculates the string length of the utf-8 encoded string.

Same problem occures in Safari-2.0.4 if in the request the content-type header is set to something different from &quot;text/javascript&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>458973</commentid>
    <comment_count>2</comment_count>
    <who name="Jiri Kaderavek">jiri.kaderavek</who>
    <bug_when>2006-08-08 11:26:15 +0000</bug_when>
    <thetext>Duplicate bug #119391</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>462791</commentid>
    <comment_count>3</comment_count>
      <attachid>17476</attachid>
    <who name="James Thorniley">james_thorniley</who>
    <bug_when>2006-08-23 23:34:54 +0000</bug_when>
    <thetext>Created attachment 17476
Patch (fixes test case for me)

Attached patch fixes the issue for me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>462943</commentid>
    <comment_count>4</comment_count>
    <who name="Jan Mentzel">jan_mentzel</who>
    <bug_when>2006-08-24 14:51:44 +0000</bug_when>
    <thetext>Patch fixes issue for me too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>462955</commentid>
    <comment_count>5</comment_count>
    <who name="Germain Garand">germain</who>
    <bug_when>2006-08-24 15:36:38 +0000</bug_when>
    <thetext>SVN commit 576640 by ggarand:

apply patch by James Thorniley&lt;james_thorniley@yahoo.co.uk&gt;

for &quot;xmlhttprequest breaks on utf-8 strings&quot;

BUG:131242



 M  +1 -1      xmlhttprequest.cpp  


--- branches/KDE/3.5/kdelibs/khtml/ecma/xmlhttprequest.cpp #576639:576640
@@ -335,7 +335,7 @@
     // FIXME: determine post encoding correctly by looking in headers
     // for charset.
     QByteArray buf;
-    buf.duplicate(_body.utf8().data(), _body.length());
+    buf.duplicate(_body.utf8().data(), _body.utf8().length());
 
     job = KIO::http_post( url, buf, false );
     if(contentType.isNull())
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>462971</commentid>
    <comment_count>6</comment_count>
    <who name="David Faure">faure</who>
    <bug_when>2006-08-24 16:19:52 +0000</bug_when>
    <thetext>SVN commit 576656 by dfaure:

Calling utf8() twice is expensive, calling length() on a QCString is expensive, so better not do either one :)
CCBUG: 131242


 M  +2 -1      xmlhttprequest.cpp  


--- branches/KDE/3.5/kdelibs/khtml/ecma/xmlhttprequest.cpp #576655:576656
@@ -335,7 +335,8 @@
     // FIXME: determine post encoding correctly by looking in headers
     // for charset.
     QByteArray buf;
-    buf.duplicate(_body.utf8().data(), _body.utf8().length());
+    QCString str = _body.utf8();
+    buf.duplicate(str.data(), str.size() - 1);
 
     job = KIO::http_post( url, buf, false );
     if(contentType.isNull())
</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>17476</attachid>
            <date>2006-08-23 23:34:54 +0000</date>
            <delta_ts>2006-08-23 23:34:54 +0000</delta_ts>
            <desc>Patch (fixes test case for me)</desc>
            <filename>xmlhttprequest-post-utf8.diff</filename>
            <type>text/plain</type>
            <size>538</size>
            <attacher name="James Thorniley">james_thorniley</attacher>
            
              <data encoding="base64">SW5kZXg6IGtodG1sL2VjbWEveG1saHR0cHJlcXVlc3QuY3BwCj09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGtodG1s
L2VjbWEveG1saHR0cHJlcXVlc3QuY3BwCShyZXZpc2lvbiA1NzU5NzkpCisrKyBraHRtbC9lY21h
L3htbGh0dHByZXF1ZXN0LmNwcAkod29ya2luZyBjb3B5KQpAQCAtMzM1LDcgKzMzNSw3IEBACiAg
ICAgLy8gRklYTUU6IGRldGVybWluZSBwb3N0IGVuY29kaW5nIGNvcnJlY3RseSBieSBsb29raW5n
IGluIGhlYWRlcnMKICAgICAvLyBmb3IgY2hhcnNldC4KICAgICBRQnl0ZUFycmF5IGJ1ZjsKLSAg
ICBidWYuZHVwbGljYXRlKF9ib2R5LnV0ZjgoKS5kYXRhKCksIF9ib2R5Lmxlbmd0aCgpKTsKKyAg
ICBidWYuZHVwbGljYXRlKF9ib2R5LnV0ZjgoKS5kYXRhKCksIF9ib2R5LnV0ZjgoKS5sZW5ndGgo
KSk7CiAKICAgICBqb2IgPSBLSU86Omh0dHBfcG9zdCggdXJsLCBidWYsIGZhbHNlICk7CiAgICAg
aWYoY29udGVudFR5cGUuaXNOdWxsKCkpCg==
</data>

          </attachment>
      

    </bug>

</bugzilla>