Re: [PATCH 3/7] Extract, test and enhance the logic to collapse ../foo paths.
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Sep 26, 2012, 22:43 UTC
- Message-ID
- <20120926224307.GA31456@elie.Belkin>
- In-Reply-To
- <20120926215429.GA4637@dcvr.yhbt.net>
Eric Wong wrote:
> It should probably just return the root path ("c:/" and
> "http://www.example.com/" respectively).That means recognizing drive letters and URLs. Hm.
Subversion commands seem to use svn_client_args_to_target_array2 to canonicalize arguments. It does something like the following:
1. split at @PEG revision 2. check if it looks like a URL (svn_path_is_url). If so:
i. urlencode characters with high bit set (svn_path_uri_from_iri)
ii. urlencode some other special characters (svn_path_uri_autoescape)
(that is: [ "<>\\^`{|}])
iii. (on Windows) convert backslashes to forward slashes
iv. complain if there are any '..' (svn_path_is_backpath_present)
v. make url scheme and hostname lowercase, strip default portnumber,
strip trailing '/', collapse '/'-es including urlencoded %2F,
strip '.' and '%2E' components, make drive letter in file:///
URLs uppercase, urlencode uri-special characters
(svn_uri_canonicalize)Otherwise:
i. canonicalize case, handle '..' and '.' components, and make
path separators into '/'
(apr_filepath_merge(APR_FILEPATH_TRUENAME))
ii. strip trailing '/', collapse '/'-es except in UNC paths,
strip '.' components, make drive letter uppercase
(svn_dirent_canonicalize)
iii. deal with "truepath collisions" (unwanted case
canonicalizations)
iv. reject .svn and _svn directoriesMaybe we can use apr_filepath_merge() to avoid reinventing the wheel?