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

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:47:33 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit e5f4477cca5551946fe0141b13c28a3572235037
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jul 16 16:54:00 2003 +0000

            Reviewed by Richard
    
            * kwq/KWQKURL.h:
            * kwq/KWQKURL.mm:
            (StringHasCaseInsensitivePrefix): Helper method for the new functions below
            (StringByAddingPercentEscapes): Ditto
            (URLStringByAddingPercentEscapes): Ditto
            (KURL::getNSURL): Added convenience function to get an NSURL from a KURL
            (KURL::getNSData): Added convenience function to get an NSData from a KURL
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4659 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index ee807fe..cf9e1a6 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,15 @@
+2003-07-15  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Richard
+	
+        * kwq/KWQKURL.h:
+        * kwq/KWQKURL.mm:
+        (StringHasCaseInsensitivePrefix): Helper method for the new functions below
+        (StringByAddingPercentEscapes): Ditto
+        (URLStringByAddingPercentEscapes): Ditto
+        (KURL::getNSURL): Added convenience function to get an NSURL from a KURL
+        (KURL::getNSData): Added convenience function to get an NSData from a KURL
+
 2003-07-15  Richard Williamson   <rjw at apple.com>
 
 	Fixed 3315951:  Add support for <OL>, <UL> in attributed string conversion.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index ee807fe..cf9e1a6 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,15 @@
+2003-07-15  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Richard
+	
+        * kwq/KWQKURL.h:
+        * kwq/KWQKURL.mm:
+        (StringHasCaseInsensitivePrefix): Helper method for the new functions below
+        (StringByAddingPercentEscapes): Ditto
+        (URLStringByAddingPercentEscapes): Ditto
+        (KURL::getNSURL): Added convenience function to get an NSURL from a KURL
+        (KURL::getNSData): Added convenience function to get an NSData from a KURL
+
 2003-07-15  Richard Williamson   <rjw at apple.com>
 
 	Fixed 3315951:  Add support for <OL>, <UL> in attributed string conversion.
diff --git a/WebCore/kwq/KWQKURL.h b/WebCore/kwq/KWQKURL.h
index c5b3826..b14a45a 100644
--- a/WebCore/kwq/KWQKURL.h
+++ b/WebCore/kwq/KWQKURL.h
@@ -32,6 +32,14 @@
 
 class QTextCodec;
 
+#ifdef __OBJC__
+ at class NSData;
+ at class NSURL;
+#else
+class NSData;
+class NSURL;
+#endif
+
 class KURL {
 public:
     KURL();
@@ -71,6 +79,9 @@ public:
 
     QString prettyURL() const;
     
+    NSURL *getNSURL() const;
+    NSData *getNSData() const;
+    
     static QString decode_string(const QString &);
     static QString encode_string(const QString &);
     
diff --git a/WebCore/kwq/KWQKURL.mm b/WebCore/kwq/KWQKURL.mm
index 6e17fb3..8460e82 100644
--- a/WebCore/kwq/KWQKURL.mm
+++ b/WebCore/kwq/KWQKURL.mm
@@ -1247,3 +1247,82 @@ QString KURL::encode_string(const QString& notEncodedString)
 
     return result;
 }
+
+
+// The following three helper functions provide some temporary support for
+// converting a KURL to an NSURL.
+// These functions will be removed when the new CFURL API to create
+// "web-compatible" URLs are available.
+
+bool StringHasCaseInsensitivePrefix(NSString *string, NSString *prefix)
+{
+    return [string rangeOfString:prefix options:(NSCaseInsensitiveSearch | NSAnchoredSearch)].location != NSNotFound;
+}
+
+static NSString *StringByAddingPercentEscapes(NSString *string)
+{
+    return [(NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)string, CFSTR("%"), NULL, kCFStringEncodingUTF8) autorelease];
+}
+
+static NSString *URLStringByAddingPercentEscapes(NSString *string)
+{
+    // Work around CFURL bug/issue 2711611.
+    
+    // Don't munge IPv6 host numbers.
+    unsigned afterIPv6HostNumber = 0;
+    if (StringHasCaseInsensitivePrefix(string, @"http://[")) {
+        NSRange endBracket = [string rangeOfString:@"]" options:NSLiteralSearch];
+        if (endBracket.location != NSNotFound) {
+            afterIPv6HostNumber = NSMaxRange(endBracket);
+        }
+    }
+    
+    // Don't munge the first # in the string.
+    NSRange firstPoundSign = [string rangeOfString:@"#" options:NSLiteralSearch
+        range:NSMakeRange(afterIPv6HostNumber, [string length] - afterIPv6HostNumber)];
+
+    // Handle the common case first for a little speed.
+    if (afterIPv6HostNumber == 0 && firstPoundSign.location == NSNotFound) {
+        return StringByAddingPercentEscapes(string);
+    }
+
+    // And the "no fragment" case.
+    if (firstPoundSign.location == NSNotFound) {
+        return [NSString stringWithFormat:@"%@%@",
+            [string substringToIndex:afterIPv6HostNumber],
+            StringByAddingPercentEscapes([string substringFromIndex:afterIPv6HostNumber])];
+    }
+
+    // Now the "with fragment" case.
+    ASSERT(afterIPv6HostNumber <= firstPoundSign.location);
+    return [NSString stringWithFormat:@"%@%@#%@",
+        [string substringToIndex:afterIPv6HostNumber],
+        StringByAddingPercentEscapes([string substringWithRange:NSMakeRange
+            (afterIPv6HostNumber, firstPoundSign.location - afterIPv6HostNumber)]),
+        StringByAddingPercentEscapes([string substringFromIndex:NSMaxRange(firstPoundSign)])];
+}
+
+
+NSURL *KURL::getNSURL() const
+{
+    // Use old-style conversion of a string to a URL until 
+    // new CF-level API is available to do conversion.
+    // This uses the same methodology to convert to an
+    // NSURL as is used inside Foundation:
+    NSMutableString *string = [[url().getNSString() mutableCopy] autorelease];
+    return [NSURL URLWithString:URLStringByAddingPercentEscapes(string)];
+
+#if 0
+    // This is the new-style conversion scheme we want to use when the new CFURL
+    // APIs are available
+    const UInt8 *bytes = (const UInt8 *)(urlString.latin1());
+    return (NSURL *)CFURLCreateAbsoluteURLWithBytes(NULL, bytes, urlString.length(), kCFStringEncodingISOLatin1, NULL, TRUE);
+#endif
+    
+}
+
+NSData *KURL::getNSData() const
+{
+    const UInt8 *bytes = (const UInt8 *)(urlString.latin1());
+    return [NSData dataWithBytes:bytes length:urlString.length()];
+}

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list