subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmpil...@apache.org
Subject svn commit: r1068476 - in /subversion/trunk/subversion: libsvn_subr/dirent_uri.c tests/libsvn_subr/dirent_uri-test.c
Date Tue, 08 Feb 2011 16:56:49 GMT
Author: cmpilato
Date: Tue Feb  8 16:56:49 2011
New Revision: 1068476

URL: http://svn.apache.org/viewvc?rev=1068476&view=rev
Log:
Fix some failing canonicalization scenarios.

* subversion/libsvn_subr/dirent_uri.c
  (canonicalize): Teach this function to consistently treat "%2F" as
    slashes and "%2E" as periods in URIs.

* subversion/tests/libsvn_subr/dirent_uri-test.c
  (test_uri_canonicalize): Uncomment some previously failing test
    data.  Thems don't fail no' mo'.

Modified:
    subversion/trunk/subversion/libsvn_subr/dirent_uri.c
    subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c

Modified: subversion/trunk/subversion/libsvn_subr/dirent_uri.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/dirent_uri.c?rev=1068476&r1=1068475&r2=1068476&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/dirent_uri.c (original)
+++ subversion/trunk/subversion/libsvn_subr/dirent_uri.c Tue Feb  8 16:56:49 2011
@@ -473,22 +473,34 @@ canonicalize(path_type_t type, const cha
 
   while (*src)
     {
-      /* Parse each segment, find the closing '/' */
+      /* Parse each segment, finding the closing '/' (which might look
+         like '%2F' for URIs).  */
       const char *next = src;
-      while (*next && (*next != '/'))
-        ++next;
+      apr_size_t slash_len = 0;
 
+      while (*next
+             && (next[0] != '/')
+             && (! (type == type_uri && next[0] == '%' && next[1]
== '2' &&
+                    canonicalize_to_upper(next[2]) == 'F')))
+        {
+          ++next;
+        }
+
+      /* Record how long our "slash" is. */
+      if (next[0] == '/')
+        slash_len = 1;
+      else if (type == type_uri && next[0] == '%')
+        slash_len = 3;
+      
       seglen = next - src;
 
-      if (seglen == 0 || (seglen == 1 && src[0] == '.'))
+      if (seglen == 0 
+          || (seglen == 1 && src[0] == '.')
+          || (type == type_uri && seglen == 3 && src[0] == '%' &&
src[1] == '2'
+              && canonicalize_to_upper(src[2]) == 'E'))
         {
-          /* Noop segment, so do nothing. */
-        }
-      else if (type == type_uri && seglen == 3
-               && src[0] == '%' && src[1] == '2'
-               && canonicalize_to_upper(src[2]) == 'E')
-        {
-          /* '%2E' is equivalent to '.', so this is a noop segment */
+          /* Empty or noop segment, so do nothing.  (For URIs, '%2E'
+             is equivalent to '.').  */
         }
 #ifdef SVN_USE_DOS_PATHS
       /* If this is the first path segment of a file:// URI and it contains a
@@ -507,17 +519,15 @@ canonicalize(path_type_t type, const cha
       else
         {
           /* An actual segment, append it to the destination path */
-          if (*next)
-            seglen++;
           memcpy(dst, src, seglen);
           dst += seglen;
+          if (slash_len)
+            *(dst++) = '/';
           canon_segments++;
         }
 
       /* Skip over trailing slash to the next segment. */
-      src = next;
-      if (*src)
-        src++;
+      src = next + slash_len;
     }
 
   /* Remove the trailing slash if there was at least one

Modified: subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c?rev=1068476&r1=1068475&r2=1068476&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c Tue Feb  8 16:56:49 2011
@@ -838,9 +838,8 @@ test_uri_canonicalize(apr_pool_t *pool)
     { "http://server/ ",       "http://server/%20" },
     { "http://server/#",       "http://server/%23" },
     { "http://server/d/a%2Fb", "http://server/d/a/b" },
-    /* ### These tests fail to notice that %2F is '/'.
     { "http://server/d/.%2F.", "http://server/d" },
-    { "http://server/d/%2E%2F%2E", "http://server/d" }, */
+    { "http://server/d/%2E%2F%2E", "http://server/d" },
     { "file:///C%3a/temp",     "file:///C:/temp" },
     { "http://server/cr%AB",   "http://server/cr%AB" },
     { "http://server/cr%ab",   "http://server/cr%AB" },



Mime
View raw message