<?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>108400</bug_id>
          
          <creation_ts>2005-07-01 14:43:33 +0000</creation_ts>
          <short_desc>XMLHttpRequest doesn&apos;t handle document charset</short_desc>
          <delta_ts>2005-09-25 16:52:55 +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>khtml</component>
          <version>unspecified</version>
          <rep_platform>Gentoo Packages</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>0</everconfirmed>
          <reporter name="Michael Krelin">kdeer</reporter>
          <assigned_to name="Konqueror Bugs">konqueror-bugs-null</assigned_to>
          
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>354690</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Krelin">kdeer</who>
    <bug_when>2005-07-01 14:43:33 +0000</bug_when>
    <thetext>Version:            (using KDE KDE 3.4.1)
Installed from:    Gentoo Packages
Compiler:          gcc 3 
OS:                Linux

When I am trying to load an html fragment via XMLHttpRequest() and display it via *.innerHTML = *.responseText it shows up, I believe, in Latin encoding. Which is not the case for Firefox, MSIE and Opera.

You can check out the behaviour at 

http://hacker.klever.net/range/konqueror-charset-bug/

which loads http://hacker.klever.net/range/konqueror-charset-bug/to-load.html

Both documents return Content-Type: text/html; charset=windows-1251</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>354807</commentid>
    <comment_count>1</comment_count>
    <who name="Thiago Macieira">thiago</who>
    <bug_when>2005-07-02 02:48:52 +0000</bug_when>
    <thetext>I can reproduce (trunk 424191).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>357953</commentid>
    <comment_count>2</comment_count>
    <who name="Dawit Alemayehu">adawit</who>
    <bug_when>2005-07-15 00:58:56 +0000</bug_when>
    <thetext>The attached patch should fix the problem. 

On Friday 01 July 2005 20:48, Thiago Macieira wrote:
[bugs.kde.org quoted mail]


Created an attachment (id=11811)
xmlhttprequest.diff</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>357969</commentid>
    <comment_count>3</comment_count>
    <who name="Thiago Macieira">thiago</who>
    <bug_when>2005-07-15 03:31:30 +0000</bug_when>
    <thetext>I can confirm it fixes the problem. If you&apos;ll be so kind, Dawit, commit it :-)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>358072</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Krelin">kdeer</who>
    <bug_when>2005-07-15 13:42:40 +0000</bug_when>
    <thetext>Great, I&apos;ve seen you working in the logs ;-)

Hope it&apos;s okay if I eventually remove the files I&apos;ve put on the web.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>358088</commentid>
    <comment_count>5</comment_count>
    <who name="Dawit Alemayehu">adawit</who>
    <bug_when>2005-07-15 15:48:09 +0000</bug_when>
    <thetext>SVN commit 434817 by adawit:

- Use the charset provided by the remote host through the HTTP headers.

BUG: 108400@bugs.kde.org



 M  +12 -0     xmlhttprequest.cpp  


--- trunk/KDE/kdelibs/khtml/ecma/xmlhttprequest.cpp #434816:434817
@@ -553,6 +553,18 @@
 #endif
 
   if ( decoder == NULL ) {
+     int pos = responseHeaders.find(&quot;Content-Type:&quot;);
+     if ( pos &gt; -1 )
+     {
+        int index = responseHeaders.find(&apos;\n&apos;, pos+13);
+        QString type = responseHeaders.mid(pos+13, index);
+        // qDebug(&quot;XMLHttpRequest::slotData: &apos;content-type = %s&apos;&quot;, type.latin1());
+        index = type.find (&apos;;&apos;);
+        if (index &gt; -1)
+          encoding = type.mid( index+1 ).remove(QRegExp(&quot;charset[ ]*=[ ]*&quot;, false)).stripWhiteSpace();
+        // qDebug(&quot;XMLHttpRequest::slotData: &apos;encoding = %s&apos;&quot;, encoding.latin1());
+     }
+
     decoder = new Decoder;
     if (!encoding.isNull())
       decoder-&gt;setEncoding(encoding.latin1(), Decoder::EncodingFromHTTPHeader);
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>375948</commentid>
    <comment_count>6</comment_count>
    <who name="Anton">anton.bugs</who>
    <bug_when>2005-09-25 16:52:53 +0000</bug_when>
    <thetext>guys, your patch doesn&apos;t work for me.
Please double check.

Cheers,
Anton

ps. I think you have to apply it &quot;encoding&quot; after 
if (!encoding.isNull()) 
        decoder-&gt;setEncoding(encoding.latin1(), Decoder::EncodingFromHTTPHeader); 

In the &quot;fixme&quot; line.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>11811</attachid>
            <date>2005-07-15 00:58:56 +0000</date>
            <delta_ts>2005-07-15 00:58:56 +0000</delta_ts>
            <desc>xmlhttprequest.diff</desc>
            <filename>xmlhttprequest.diff</filename>
            <type>text/x-diff</type>
            <size>913</size>
            <attacher name="Dawit Alemayehu">adawit</attacher>
            
              <data encoding="base64">SW5kZXg6IHhtbGh0dHByZXF1ZXN0LmNwcAo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSB4bWxodHRwcmVxdWVzdC5j
cHAJKHJldmlzaW9uIDQzNDY0MikKKysrIHhtbGh0dHByZXF1ZXN0LmNwcAkod29ya2luZyBjb3B5
KQpAQCAtNTUzLDYgKzU1MywxOCBAQAogI2VuZGlmCiAKICAgaWYgKCBkZWNvZGVyID09IE5VTEwg
KSB7CisgICAgIGludCBwb3MgPSByZXNwb25zZUhlYWRlcnMuZmluZCgiQ29udGVudC1UeXBlOiIp
OworICAgICBpZiAoIHBvcyA+IC0xICkKKyAgICAgeworICAgICAgICBpbnQgaW5kZXggPSByZXNw
b25zZUhlYWRlcnMuZmluZCgnXG4nLCBwb3MrMTMpOworICAgICAgICBRU3RyaW5nIHR5cGUgPSBy
ZXNwb25zZUhlYWRlcnMubWlkKHBvcysxMywgaW5kZXgpOworICAgICAgICAvLyBxRGVidWcoIlhN
TEh0dHBSZXF1ZXN0OjpzbG90RGF0YTogJ2NvbnRlbnQtdHlwZSA9ICVzJyIsIHR5cGUubGF0aW4x
KCkpOworICAgICAgICBpbmRleCA9IHR5cGUuZmluZCAoJzsnKTsKKyAgICAgICAgaWYgKGluZGV4
ID4gLTEpCisgICAgICAgICAgZW5jb2RpbmcgPSB0eXBlLm1pZCggaW5kZXgrMSApLnJlbW92ZShR
UmVnRXhwKCJjaGFyc2V0WyBdKj1bIF0qIiwgZmFsc2UpKS5zdHJpcFdoaXRlU3BhY2UoKTsKKyAg
ICAgICAgLy8gcURlYnVnKCJYTUxIdHRwUmVxdWVzdDo6c2xvdERhdGE6ICdlbmNvZGluZyA9ICVz
JyIsIGVuY29kaW5nLmxhdGluMSgpKTsKKyAgICAgfQorCiAgICAgZGVjb2RlciA9IG5ldyBEZWNv
ZGVyOwogICAgIGlmICghZW5jb2RpbmcuaXNOdWxsKCkpCiAgICAgICBkZWNvZGVyLT5zZXRFbmNv
ZGluZyhlbmNvZGluZy5sYXRpbjEoKSwgRGVjb2Rlcjo6RW5jb2RpbmdGcm9tSFRUUEhlYWRlcik7
Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>