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

List:       kde-core-devel
Subject:    [PATCH] Fix for bug 70753: charset not detected when more than one
From:       Thiago Macieira <thiago.macieira () kdemail ! net>
Date:       2003-12-18 17:59:28
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Hello,

I the attached patch fixes bug #70753. When receiving a header like:
Content-Type: text/html; charset=ISO-8859-4; charset=ISO-8859-4 

kio_http sets the "charset" metadata to:
"iso-8859-4; charset=iso-8859-4"

That is, it ignores the second ; and treats the rest of the line after the = 
as one single parameter.

The attached patch solves that by making it treat each parameter 
independently, separated by ;

Is it ok to commit?
-- 
  Thiago Macieira  -  Registered Linux user #65028
   thiagom (AT) mail (dot) com
    ICQ UIN: 1967141   PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

["kio_http-doublecharset.patch" (text/x-diff)]

Index: http.cc
===================================================================
RCS file: /home/kde/kdelibs/kioslave/http/http.cc,v
retrieving revision 1.600
diff -u -3 -p -r1.600 http.cc
--- http.cc	12 Dec 2003 07:59:05 -0000	1.600
+++ http.cc	18 Dec 2003 17:52:00 -0000
@@ -2901,15 +2901,19 @@ bool HTTPProtocol::readHeader()
 
       // 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...
-      if (*pos)
+      while (*pos)
       {
         start = ++pos;
         while ( *pos && *pos != '=' )  pos++;
 
+	char *end = pos;
+	while ( *end && *end != ';' )  end++;
+
         if (*pos)
         {
           mediaAttribute = QString::fromLatin1(start, pos-start).stripWhiteSpace().lower();
-          mediaValue = QString::fromLatin1(++pos).stripWhiteSpace();
+          mediaValue = QString::fromLatin1(++pos, end-pos).stripWhiteSpace();
+	  pos = end;
           if (mediaValue.length() &&
               (mediaValue[0] == '"') &&
               (mediaValue[mediaValue.length()-1] == '"'))
@@ -2920,14 +2924,14 @@ bool HTTPProtocol::readHeader()
           kdDebug (7113) << "(" << m_pid << ") Media-Parameter Value: "
                          << mediaValue << endl;
 
-          if ( mediaAttribute.lower() == "charset")
+          if ( mediaAttribute == "charset")
           {
             mediaValue = mediaValue.lower();
             m_request.strCharset = mediaValue;
           }
           else
           {
-            setMetaData("media-"+mediaAttribute.lower(), mediaValue);
+            setMetaData("media-"+mediaAttribute, mediaValue);
           }
         }
       }

[Attachment #6 (application/pgp-signature)]

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

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