diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-09-23 12:55:25 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-09-23 13:04:57 (GMT) |
commit | 7dedc5699842d2651859e36b0ca843ec4d173056 (patch) | |
tree | 41fd43ad580b330abddea17740a17bec394d13d2 /src | |
parent | a33c1ca39ef8cb2485dbde3c0454873f58c0b733 (diff) | |
download | Qt-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')
-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 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); + } } } } |