Summary: | XMLHttpRequest doesn't handle document charset | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | Michael Krelin <kdeer> |
Component: | khtml | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | xmlhttprequest.diff |
Description
Michael Krelin
2005-07-01 14:43:33 UTC
I can reproduce (trunk 424191). 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 I can confirm it fixes the problem. If you'll be so kind, Dawit, commit it :-) Great, I've seen you working in the logs ;-) Hope it's okay if I eventually remove the files I've put on the web. 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("Content-Type:"); + if ( pos > -1 ) + { + int index = responseHeaders.find('\n', pos+13); + QString type = responseHeaders.mid(pos+13, index); + // qDebug("XMLHttpRequest::slotData: 'content-type = %s'", type.latin1()); + index = type.find (';'); + if (index > -1) + encoding = type.mid( index+1 ).remove(QRegExp("charset[ ]*=[ ]*", false)).stripWhiteSpace(); + // qDebug("XMLHttpRequest::slotData: 'encoding = %s'", encoding.latin1()); + } + decoder = new Decoder; if (!encoding.isNull()) decoder->setEncoding(encoding.latin1(), Decoder::EncodingFromHTTPHeader); guys, your patch doesn't work for me. Please double check. Cheers, Anton ps. I think you have to apply it "encoding" after if (!encoding.isNull()) decoder->setEncoding(encoding.latin1(), Decoder::EncodingFromHTTPHeader); In the "fixme" line. |