[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:37:18 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 34d95b3fed8ef4e29b363f22fc60080b0f5ee0bc
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Apr 27 04:20:09 2004 +0000

            Reviewed by Maciej.
    
            - follow-on to fix for <rdar://problem/3488892>: "anchor names with non-ASCII characters in them do not work"
            This part fixes anchor names with non-ASCII characters in local files.
    
            * kwq/KWQKURL.mm: (KURL::KURL): For file and help URLs, force UTF-8 only for the path part of the URL.
            Use the document encoding for the rest of the URL.
            * kwq/KWQTextCodec.h: (operator!=): Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6493 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 5e19ae9..3856f23 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,14 @@
+2004-04-26  Darin Adler  <darin at apple.com>
+
+        Reviewed by Maciej.
+
+        - follow-on to fix for <rdar://problem/3488892>: "anchor names with non-ASCII characters in them do not work"
+        This part fixes anchor names with non-ASCII characters in local files.
+
+        * kwq/KWQKURL.mm: (KURL::KURL): For file and help URLs, force UTF-8 only for the path part of the URL.
+        Use the document encoding for the rest of the URL.
+        * kwq/KWQTextCodec.h: (operator!=): Added.
+
 2004-04-26  David Hyatt  <hyatt at apple.com>
 
 	Fix for Emerson truncation problem using apple-line-clamp.  Always dirty positioned objects so that they
diff --git a/WebCore/kwq/KWQKURL.mm b/WebCore/kwq/KWQKURL.mm
index a7ffe59..1c8ad31 100644
--- a/WebCore/kwq/KWQKURL.mm
+++ b/WebCore/kwq/KWQKURL.mm
@@ -338,9 +338,16 @@ KURL::KURL(const KURL &base, const QString &relative, const QTextCodec *codec)
         QString s = relative;
 #endif
 
-        // Always use UTF-8 if the protocol is file, mailto, or help because that's
-        // what these protocols expect.
-        if (codec) {
+        static const QTextCodec UTF8Codec(kCFStringEncodingUTF8);
+
+        const QTextCodec *pathCodec = codec ? codec : &UTF8Codec;
+        const QTextCodec *otherCodec = pathCodec;
+
+        // Always use UTF-8 for mailto URLs because that's what mail applications expect.
+        // Always use UTF-8 for paths in file and help URLs, since they are local filesystem paths,
+        // and help content is often defined with this in mind, but use native encoding for the
+        // non-path parts of the URL.
+        if (*pathCodec != UTF8Codec) {
             QString protocol;
             if (relative.length() > 0 && isSchemeFirstChar(relative.at(0).latin1())) {
                 for (uint i = 1; i < relative.length(); i++) {
@@ -358,15 +365,31 @@ KURL::KURL(const KURL &base, const QString &relative, const QTextCodec *codec)
                 protocol = base.protocol();
             }
             protocol = protocol.lower();
-            if (protocol == "file" || protocol == "mailto" || protocol == "help") {
-                codec = NULL;
+            if (protocol == "file" || protocol == "help") {
+                pathCodec = &UTF8Codec;
+            } else if (protocol == "mailto") {
+                pathCodec = &UTF8Codec;
+                otherCodec = &UTF8Codec;
             }
         }
 
-        static QTextCodec UTF8Codec(kCFStringEncodingUTF8);
-
-        QCString decoded = (codec ? codec : &UTF8Codec)->fromUnicode(s);
-        strBuffer = strdup(decoded);
+        int pathEnd = -1;
+        if (*pathCodec != *otherCodec) {
+            pathEnd = s.find(QRegExp("[?#]"));
+        }
+        if (pathEnd == -1) {
+            QCString decoded = pathCodec->fromUnicode(s);
+            strBuffer = strdup(decoded);
+        } else {
+            QCString pathDecoded = pathCodec->fromUnicode(s.left(pathEnd));
+            QCString otherDecoded = otherCodec->fromUnicode(s.mid(pathEnd));
+            int pathDecodedLength = pathDecoded.length();
+            int otherDecodedLength = otherDecoded.length();
+            strBuffer = static_cast<char *>(malloc(pathDecodedLength + otherDecodedLength + 1));
+            memcpy(strBuffer, pathDecoded, pathDecodedLength);
+            memcpy(strBuffer + pathDecodedLength, otherDecoded, otherDecodedLength);
+            strBuffer[pathDecodedLength + otherDecodedLength] = 0;
+        }
         str = strBuffer;
     }
     
@@ -893,7 +916,7 @@ QString KURL::prettyURL() const
 
 QString KURL::decode_string(const QString &urlString, const QTextCodec *codec)
 {
-    static QTextCodec UTF8Codec(kCFStringEncodingUTF8);
+    static const QTextCodec UTF8Codec(kCFStringEncodingUTF8);
 
     QString result("");
 
diff --git a/WebCore/kwq/KWQTextCodec.h b/WebCore/kwq/KWQTextCodec.h
index eac9626..009bfe3 100644
--- a/WebCore/kwq/KWQTextCodec.h
+++ b/WebCore/kwq/KWQTextCodec.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,7 +38,7 @@ public:
     static QTextCodec *codecForNameEightBitOnly(const char *);
     static QTextCodec *codecForLocale();
 
-    QTextCodec(CFStringEncoding e, KWQEncodingFlags f = NoEncodingFlags) : _encoding(e), _flags(f) { }
+    explicit QTextCodec(CFStringEncoding e, KWQEncodingFlags f = NoEncodingFlags) : _encoding(e), _flags(f) { }
 
     const char *name() const;
     bool usesVisualOrdering() const { return _flags & VisualOrdering; }
@@ -61,6 +61,8 @@ private:
     KWQEncodingFlags _flags;
 };
 
+inline bool operator!=(const QTextCodec &a, const QTextCodec &b) { return !(a == b); }
+
 class QTextDecoder {
 public:
     virtual ~QTextDecoder();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list