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


The following commit has been merged in the debian/unstable branch:
commit d59a43d5e49bc66b06609133540664aa39659eee
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Dec 8 01:03:36 2002 +0000

    Tests:
    
            Reviewed by: Maciej
    
    	Fix for this bug:
    
    	Radar 3073988 (URLs with /../ are not resolved before being sent to the host)
    
            * TestURLs.h: Added some new test URLs. Added a new TestAbsoluteURLsWithRelativePortions array.
            * WebFoundation-Misc/ifnsurlextensions-test.chk: Updated for changed behavior.
            * kde/Makefile.am: Added new kurl-relative-test.
            * kde/kurl-relative-test.chk: Added.
            * kde/kurl-relative-test.cpp: Added.
            * kde/kurl-test.chk: Updated for changed behavior.
    
    WebFoundation:
    
            Reviewed by: Maciej
    
            Fix for this bug:
    
            Radar 3073988 (URLs with /../ are not resolved before being sent to the host)
    
            * Misc.subproj/WebNSURLExtras.m:
            (pathRemovingDots): New code that was adapted from KURL relative URL resolution code.
            (-[NSURL _web_URLComponents]): Call new pathRemovingDots function where needed.
    
    WebCore:
    
            Reviewed by: Maciej
    
            Fix for this bug:
    
            Radar 3073988 (URLs with /../ are not resolved before being sent to the host)
    
            * kwq/KWQKURL.mm:
            (KURL::KURL):
            (copyPathRemovingDots): New function containing code that was pulled out of
    	the existing relative URL resolution code.
            (KURL::parse): Call new copyPathRemovingDots function instead of doing same work
    	inline.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2966 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index e432cff..6c3046f 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,18 @@
+2002-12-07  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by: Maciej
+
+        Fix for this bug:
+
+        Radar 3073988 (URLs with /../ are not resolved before being sent to the host)
+
+        * kwq/KWQKURL.mm:
+        (KURL::KURL):
+        (copyPathRemovingDots): New function containing code that was pulled out of 
+	the existing relative URL resolution code. 
+        (KURL::parse): Call new copyPathRemovingDots function instead of doing same work
+	inline.
+
 2002-12-06  David Hyatt  <hyatt at apple.com>
 
 	Sigh. I forgot to commit the first layer fix (that has already
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index e432cff..6c3046f 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,18 @@
+2002-12-07  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by: Maciej
+
+        Fix for this bug:
+
+        Radar 3073988 (URLs with /../ are not resolved before being sent to the host)
+
+        * kwq/KWQKURL.mm:
+        (KURL::KURL):
+        (copyPathRemovingDots): New function containing code that was pulled out of 
+	the existing relative URL resolution code. 
+        (KURL::parse): Call new copyPathRemovingDots function instead of doing same work
+	inline.
+
 2002-12-06  David Hyatt  <hyatt at apple.com>
 
 	Sigh. I forgot to commit the first layer fix (that has already
diff --git a/WebCore/kwq/KWQKURL.mm b/WebCore/kwq/KWQKURL.mm
index fc0b14e..bf50f69 100644
--- a/WebCore/kwq/KWQKURL.mm
+++ b/WebCore/kwq/KWQKURL.mm
@@ -187,6 +187,8 @@ static const unsigned char characterClassTable[256] = {
     /* 252 */ BadChar, /* 253 */ BadChar, /* 254 */ BadChar, /* 255 */ BadChar
 };
 
+static int copyPathRemovingDots(char *dst, const char *src, int srcStart, int srcEnd);
+
 // FIXME: convert to inline functions
 
 #define IS_SCHEME_FIRST_CHAR(c) (characterClassTable[(unsigned char)c] & SchemeFirstChar)
@@ -333,39 +335,7 @@ KURL::KURL(const KURL &base, const QString &relative)
 		    baseStringEnd--;
 		}
 		
-		// now copy the base path, accounting for "." and ".." segments
-		const char *baseStringPos = baseStringStart;
-		while (baseStringPos < baseStringEnd) {
-		    if (baseStringPos[0] == '.' && bufferPos[-1] == '/') {
-			if (baseStringPos[1] == '/' || baseStringPos + 1 == baseStringEnd) {
-			    // skip over "." segment
-			    baseStringPos += 2;
-			    continue;
-			} else if (baseStringPos[1] == '.' && (baseStringPos[2] == '/' ||
-							       baseStringPos + 2 == baseStringEnd)) {
-			    // skip over ".." segment and rewind the last segment
-			    // the RFC leaves it up to the app to decide what to do with excess
-			    // ".." segments - we choose to drop them since some web content
-			    // relies on this.
-			    baseStringPos += 3;
-			    if (bufferPos > bufferPathStart + 1) {
-				bufferPos--;
-			    }
-			    while (bufferPos > bufferPathStart && bufferPos[-1] != '/') {
-				bufferPos--;
-			    }
-			    // don't strip the slash before the last path segment if it was the final one
-			    if (baseStringPos[2] != '/') {
-				bufferPos++;
-			    }
-			    continue;
-			}
-		    }
-
-		    *bufferPos = *baseStringPos;
-		    baseStringPos++;
-		    bufferPos++;
-		}
+                bufferPos += copyPathRemovingDots(bufferPos, baseStringStart, 0, baseStringEnd - baseStringStart);
 
 		const char *relStringStart = relative.ascii();
 		const char *relStringPos = relStringStart;
@@ -763,6 +733,50 @@ static void appendEscapingBadChars(char*& buffer, const char *strStart, size_t l
     buffer = p;
 }
 
+// copy a path, accounting for "." and ".." segments
+static int copyPathRemovingDots(char *dst, const char *src, int srcStart, int srcEnd)
+{
+    const char *baseStringStart = src + srcStart;
+    const char *baseStringEnd = src + srcEnd;
+    char *bufferPathStart = dst;
+    const char *baseStringPos = baseStringStart;
+    
+    while (baseStringPos < baseStringEnd) {
+        if (baseStringPos[0] == '.' && dst[-1] == '/') {
+            if (baseStringPos[1] == '/' || baseStringPos + 1 == baseStringEnd) {
+                // skip over "." segment
+                baseStringPos += 2;
+                continue;
+            } else if (baseStringPos[1] == '.' && (baseStringPos[2] == '/' ||
+                                   baseStringPos + 2 == baseStringEnd)) {
+                // skip over ".." segment and rewind the last segment
+                // the RFC leaves it up to the app to decide what to do with excess
+                // ".." segments - we choose to drop them since some web content
+                // relies on this.
+                baseStringPos += 3;
+                if (dst > bufferPathStart + 1) {
+                    dst--;
+                }
+                // Note that these two while blocks differ subtly.
+                // The first helps to remove multiple adjoining slashes as we rewind.
+                while (dst > bufferPathStart && dst[-1] == '/') {
+                    dst--;
+                }
+                while (dst > bufferPathStart && dst[-1] != '/') {
+                    dst--;
+                }
+                continue;
+            }
+        }
+
+        *dst = *baseStringPos;
+        baseStringPos++;
+        dst++;
+    }
+    *dst = '\0';
+    return dst - bufferPathStart;
+}
+
 void KURL::parse(const char *url, const QString *originalString)
 {
     m_isValid = true;
@@ -909,7 +923,7 @@ void KURL::parse(const char *url, const QString *originalString)
 	while (url[pathEnd] != '\0' && url[pathEnd] != '?' && url[pathEnd] != '#') {
 	    pathEnd++;
 	}
-	
+        
 	queryStart = queryEnd = pathEnd;
 
 	if (url[queryStart] == '?') {
@@ -1023,11 +1037,30 @@ void KURL::parse(const char *url, const QString *originalString)
     if (isHTTPorHTTPS && pathEnd - pathStart == 0) {
         *p++ = '/';
     }
-   
+       
     // add path, escaping bad characters
-    appendEscapingBadChars(p, url + pathStart, pathEnd - pathStart);
+    
+    if (strstr(url, "/.") || strstr(url, "..")) {
+        char static_path_buffer[4096];
+        char *path_buffer;
+        uint pathBufferLength = pathEnd - pathStart + 1;
+        if (pathBufferLength <= sizeof(static_path_buffer)) {
+            path_buffer = static_path_buffer;
+        } else {
+            path_buffer = (char *)malloc(pathBufferLength);
+        }
+        copyPathRemovingDots(path_buffer, url, pathStart, pathEnd);
+        appendEscapingBadChars(p, path_buffer, strlen(path_buffer));
+        if (path_buffer != static_path_buffer) {
+            free(path_buffer);
+        }
+    }
+    else {
+        appendEscapingBadChars(p, url + pathStart, pathEnd - pathStart);
+    }
     pathEndPos = p - buffer;
-
+    
+    
     // add query, escaping bad characters
     appendEscapingBadChars(p, url + queryStart, queryEnd - queryStart);
     queryEndPos = p - buffer;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list