[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:51:32 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 34eff9a38587608c696f6d8a4b8ecbd5268a56b1
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 13 20:23:33 2003 +0000

    WebKit:
    
            Reviewed by Darin
    
            Fix for this bug:
    
            <rdar://problem/3374487>: URLs with UTF-8 escape sequences can't be accessed
    	when typed in the Safari location bar
    
            * Misc.subproj/WebNSPasteboardExtras.m:
            (-[NSPasteboard _web_bestURL]): Call _web_URLWithUserTypedString: to make a
    	URL from this type of string.
            * Misc.subproj/WebNSURLExtras.h:
            * Misc.subproj/WebNSURLExtras.m:
            (hexDigit): Added.
            (+[NSURL _web_URLWithUserTypedString:]): Added. Creates a URL from a string
    	that is typed in a user, for example, in the Safari location bar.
    
    WebBrowser:
    
            Reviewed by Darin
    
    	Fix for this bug:
    
    	<rdar://problem/3374487>: URLs with UTF-8 escape sequences can't be accessed
    	when typed in the Safari location bar
    
            * BrowserNSStringExtras.m:
            (-[NSString possibleURLsForUserTypedString]): Use _web_URLWithUserTypedString:
    	to make URL from this type of string.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4814 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 8b10700..4cb64a4 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,21 @@
+2003-08-13  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Darin
+
+        Fix for this bug:
+
+        <rdar://problem/3374487>: URLs with UTF-8 escape sequences can't be accessed         
+	when typed in the Safari location bar
+
+        * Misc.subproj/WebNSPasteboardExtras.m:
+        (-[NSPasteboard _web_bestURL]): Call _web_URLWithUserTypedString: to make a
+	URL from this type of string.
+        * Misc.subproj/WebNSURLExtras.h:
+        * Misc.subproj/WebNSURLExtras.m:
+        (hexDigit): Added.
+        (+[NSURL _web_URLWithUserTypedString:]): Added. Creates a URL from a string
+	that is typed in a user, for example, in the Safari location bar.
+
 2003-08-12  John Sullivan  <sullivan at apple.com>
 
 	- fixed 3369505 -- leaks of NSCFTimer after running through the 
diff --git a/WebKit/Misc.subproj/WebNSPasteboardExtras.m b/WebKit/Misc.subproj/WebNSPasteboardExtras.m
index 27b8783..f8f31d9 100644
--- a/WebKit/Misc.subproj/WebNSPasteboardExtras.m
+++ b/WebKit/Misc.subproj/WebNSPasteboardExtras.m
@@ -54,7 +54,7 @@ NSString *WebURLNamePboardType = nil;
     if ([types containsObject:NSStringPboardType]) {
         NSString *URLString = [self stringForType:NSStringPboardType];
         if ([URLString _web_looksLikeAbsoluteURL]) {
-            NSURL *URL = [[NSURL _web_URLWithDataAsString:URLString] _webkit_canonicalize];
+            NSURL *URL = [[NSURL _web_URLWithUserTypedString:URLString] _webkit_canonicalize];
             if (URL) {
                 return URL;
             }
diff --git a/WebKit/Misc.subproj/WebNSURLExtras.h b/WebKit/Misc.subproj/WebNSURLExtras.h
index f6717b5..4310ce7 100644
--- a/WebKit/Misc.subproj/WebNSURLExtras.h
+++ b/WebKit/Misc.subproj/WebNSURLExtras.h
@@ -8,6 +8,8 @@
 
 @interface NSURL (WebNSURLExtras)
 
++ (NSURL *)_web_URLWithUserTypedString:(NSString *)string;
+
 + (NSURL *)_web_URLWithDataAsString:(NSString *)string;
 + (NSURL *)_web_URLWithDataAsString:(NSString *)string relativeToURL:(NSURL *)baseURL;
 
diff --git a/WebKit/Misc.subproj/WebNSURLExtras.m b/WebKit/Misc.subproj/WebNSURLExtras.m
index 86c6024..e2e7ccb 100644
--- a/WebKit/Misc.subproj/WebNSURLExtras.m
+++ b/WebKit/Misc.subproj/WebNSURLExtras.m
@@ -22,8 +22,60 @@ static inline void ReleaseIfNotNULL(CFTypeRef object)
     }
 }
 
+static char hexDigit(int i) {
+    if (i < 0 || i > 16) {
+        ERROR("illegal hex value");
+        return '0';
+    }
+    int h = i;
+    if (h >= 10) {
+        h = h - 10 + 'a'; 
+    }
+    else {
+        h += '0';
+    }
+    return h;
+}
+
 @implementation NSURL (WebNSURLExtras)
 
++ (NSURL *)_web_URLWithUserTypedString:(NSString *)string
+{
+    if (string == nil) {
+        return nil;
+    }
+    string = [string _web_stringByTrimmingWhitespace];
+    NSData *userTypedData = [string dataUsingEncoding:NSUTF8StringEncoding];
+    ASSERT(userTypedData);
+        
+    const UInt8 *inBytes = [userTypedData bytes];
+    int inLength = [userTypedData length];
+    if (inLength == 0) {
+        return [NSURL URLWithString:@""];
+    }
+    
+    char *outBytes = malloc(inLength * 3); // large enough to %-escape every character
+    char *p = outBytes;
+    int outLength = 0;
+    int i;
+    for (i = 0; i < inLength; i++) {
+        UInt8 c = inBytes[i];
+        if (c <= 0x20 || c >= 0x7f) {
+            *p++ = '%';
+            *p++ = hexDigit(c >> 4);
+            *p++ = hexDigit(c & 0xf);
+            outLength += 3;
+        }
+        else {
+            *p++ = c;
+            outLength++;
+        }
+    }
+ 
+    NSData *data = [NSData dataWithBytesNoCopy:outBytes length:outLength]; // adopts outBytes
+    return [self _web_URLWithData:data relativeToURL:nil];
+}
+
 + (NSURL *)_web_URLWithDataAsString:(NSString *)string
 {
     if (string == nil) {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list