diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-09-23 14:55:25 +0200 |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-09-23 15:04:57 +0200 |
commit | 7dedc5699842d2651859e36b0ca843ec4d173056 (patch) | |
tree | 41fd43ad580b330abddea17740a17bec394d13d2 | |
parent | a33c1ca39ef8cb2485dbde3c0454873f58c0b733 (diff) | |
download | qt4-tools-7dedc5699842d2651859e36b0ca843ec4d173056.tar.gz |
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
-rw-r--r-- | src/corelib/codecs/qtextcodec.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 3ef9f7e5e9..4f0e13c5fe 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); + } } } } |