summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-09-23 12:55:25 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-09-23 13:04:57 (GMT)
commit7dedc5699842d2651859e36b0ca843ec4d173056 (patch)
tree41fd43ad580b330abddea17740a17bec394d13d2 /src/corelib/codecs
parenta33c1ca39ef8cb2485dbde3c0454873f58c0b733 (diff)
downloadQt-7dedc5699842d2651859e36b0ca843ec4d173056.zip
Qt-7dedc5699842d2651859e36b0ca843ec4d173056.tar.gz
Qt-7dedc5699842d2651859e36b0ca843ec4d173056.tar.bz2
Fixed parsing of html header in the qtextcodec.
The QTextCodec::codecForHtml used to expect http-equiv attribute before the charset attribute in the meta header, which is not always the case. Reviewed-by: Simon Hausmann
Diffstat (limited to 'src/corelib/codecs')
-rw-r--r--src/corelib/codecs/qtextcodec.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 3ef9f7e..4f0e13c 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -1536,12 +1536,14 @@ QTextCodec *QTextCodec::codecForHtml(const QByteArray &ba, QTextCodec *defaultCo
if (!c) {
QByteArray header = ba.left(512).toLower();
if ((pos = header.indexOf("http-equiv=")) != -1) {
- pos = header.indexOf("charset=", pos) + int(strlen("charset="));
- if (pos != -1) {
- int pos2 = header.indexOf('\"', pos+1);
- QByteArray cs = header.mid(pos, pos2-pos);
- // qDebug("found charset: %s", cs.data());
- c = QTextCodec::codecForName(cs);
+ if ((pos = header.lastIndexOf("meta ", pos)) != -1) {
+ pos = header.indexOf("charset=", pos) + int(strlen("charset="));
+ if (pos != -1) {
+ int pos2 = header.indexOf('\"', pos+1);
+ QByteArray cs = header.mid(pos, pos2-pos);
+ // qDebug("found charset: %s", cs.data());
+ c = QTextCodec::codecForName(cs);
+ }
}
}
}