Thread (38 messages) flat view 38 messages, 3 authors, 2016-06-15

Re: [PATCH 3/7] Extract, test and enhance the logic to collapse ../foo paths.

From: Michael G Schwern <hidden>
Date: 2016-06-15 22:54:23

On 2012.7.30 12:51 PM, Eric Wong wrote:
quoted
The SVN API functions will not accept ../foo but their canonicalization
functions will not collapse it.  So we'll have to do it ourselves.

_collapse_dotdot() works better than the existing regex did.
I don't dispute it's better, but it's worth explaining in the commit
message to reviewers why something is "better".
Yeah.  I figured the tests covered that.

quoted
+# Turn foo/../bar into bar
+sub _collapse_dotdot {
+	my $path = shift;
+
+	1 while $path =~ s{/[^/]+/+\.\.}{};
+	1 while $path =~ s{[^/]+/+\.\./}{};
+	1 while $path =~ s{[^/]+/+\.\.}{};
This is a bug that's gone unnoticed[1] for over 5 years now,
but I've just noticed this doesn' handle "foo/..bar"  or "foo/...bar"
cases correctly.
Good catch.  Woo unit tests!  :)  You could add them as TODO tests.

A more accurate way to do it would be to split the path, collapse using the
resulting list, and rejoin it.

[1] - I doubt anybody uses paths like these, though...
Not for an svnroot or branch name, no.


-- 
Hating the web since 1994.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help