[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bkdelibs=5D_kioslave/http=3A_Correctly_parse_the_par?=
From:       Dawit Alemayehu <adawit () kde ! org>
Date:       2011-03-01 21:28:35
Message-ID: 20110301212835.B26ADA60C9 () git ! kde ! org
[Download RAW message or body]

Git commit b648716830f16de2cb7f5efec63a6ad39c916846 by Dawit Alemayehu.
Committed on 01/03/2011 at 22:28.
Pushed by adawit into branch 'master'.

Correctly parse the parameter portion of the content-type header based on
RFC 2616 section 3.7.

BUG:266823

M  +15   -10   kioslave/http/http.cpp     

http://commits.kde.org/kdelibs/b648716830f16de2cb7f5efec63a6ad39c916846

diff --git a/kioslave/http/http.cpp b/kioslave/http/http.cpp
index c597050..9baea1a 100644
--- a/kioslave/http/http.cpp
+++ b/kioslave/http/http.cpp
@@ -3051,18 +3051,23 @@ endParsing:
             // If we still have text, then it means we have a mime-type with a
             // parameter (eg: charset=iso-8851) ; so let's get that...
             Q_FOREACH (const QByteArray &statement, l) {
-                QList<QByteArray> parts = statement.split('=');
-                if (parts.count() != 2) {
-                    continue;
+                const int index = statement.indexOf('=');
+                if (index <= 0) {
+                    mediaAttribute = toQString(statement.mid(0, index));
+                } else {
+                    mediaAttribute = toQString(statement.mid(0, index));
+                    mediaValue = toQString(statement.mid(index+1));
                 }
-                mediaAttribute = toQString(parts[0].trimmed().toLower());
-                mediaValue = toQString(parts[1].trimmed());
-                if (mediaValue.length() && (mediaValue[0] == QLatin1Char('"')) &&
-                    (mediaValue[mediaValue.length() - 1] == QLatin1Char('"'))) {
-                    mediaValue = mediaValue.mid(1, mediaValue.length() - 2);
+
+                if (mediaValue.startsWith(QLatin1Char('"'))) {
+                    mediaValue.remove(QLatin1Char('"'));
                 }
-                kDebug (7113) << "Encoding-type:" << mediaAttribute
-                              << "=" << mediaValue;
+
+                if (mediaValue.endsWith(QLatin1Char('"'))) {
+                    mediaValue.truncate(mediaValue.length()-1);
+                }
+
+                kDebug (7113) << "Encoding-type:" << mediaAttribute << "=" << mediaValue;
 
                 if (mediaAttribute == QLatin1String("charset")) {
                     mediaValue = mediaValue.toLower();

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic