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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2012.7.30 12:51 PM, Eric Wong wrote:
>> 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.


>> +# 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]