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

List:       kde-commits
Subject:    kdelibs/khtml/misc
From:       Maks Orlovich <maksim () kde ! org>
Date:       2005-01-29 16:47:46
Message-ID: 20050129164746.D74421D169 () office ! kde ! org
[Download RAW message or body]

CVS commit by orlovich: 

If an ASCII-encoded META tag specifies UTF-16, it's clearly lying, so ignore it (WebCore 
implements a similar check)

Also a fixlet to make it build with DECODE_DEBUG
BUG:98130


  M +10 -1     decoder.cpp   1.76


--- kdelibs/khtml/misc/decoder.cpp  #1.75:1.76
@@ -73,5 +73,5 @@ void Decoder::setEncoding(const char *_e
 {
 #ifdef DECODE_DEBUG
-    kdDebug(6005) << "setEncoding " << _encoding << " " << force << endl;
+    kdDebug(6005) << "setEncoding " << _encoding << " " << type << endl;
 #endif
     enc = _encoding;
@@ -102,4 +102,12 @@ void Decoder::setEncoding(const char *_e
         codec = 0;
 
+    if (type == EncodingFromMetaTag || type  == EncodingFromXMLHeader) {
+        //Sometimes the codec specified is absurd, i.e. UTF-16 despite
+        //us decoding a meta tag as ASCII. In that case, ignore it.
+        if (codec && 
+            (codec->mibEnum() == 1000)) //UTF16 or similar. 
+                codec = 0;
+    }
+
     if (codec && codec->mibEnum() == 11)  {
         // visually ordered unless one of the following
@@ -446,4 +454,5 @@ QString Decoder::decode(const char *data
         case Decoder::Unicode:
             // huh. somethings broken in this code ### FIXME
+            enc = 0; //Reset invalid codec we tried, so we get back to latin1 fallback.
             break;
         }


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

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