summaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-02-24 13:50:29 +0100
committerMax Kellermann <max@musicpd.org>2017-02-24 13:50:29 +0100
commitcd522f524dd95824ade3a41f1aeddf428fa7cc19 (patch)
tree22e0143d9d9549dc7b64b132b40de83d0ae41f04 /src/fs
parentca559b1db66060add5468c4e77f8c891b0a8604a (diff)
fs/Traits: allow base to end with a slash in Relative()
Fixes false negatives: http://foo/dav/example.ogg mismatches http://foo/dav/ .. because StringAfterPrefix() returns just "example.ogg", without trailing slash (it existed, but was eaten already by the base matcher).
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/Traits.cxx9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/fs/Traits.cxx b/src/fs/Traits.cxx
index c3f10a51a..45a2ffacf 100644
--- a/src/fs/Traits.cxx
+++ b/src/fs/Traits.cxx
@@ -99,9 +99,16 @@ RelativePathImpl(typename Traits::const_pointer_type base,
return nullptr;
if (*other != 0) {
- if (!Traits::IsSeparator(*other))
+ if (!Traits::IsSeparator(*other)) {
+ if (*base != 0 && Traits::IsSeparator(other[-1]))
+ /* "other" has no more slash, but the
+ matching base ended with a slash:
+ enough to detect a match */
+ return other;
+
/* mismatch */
return nullptr;
+ }
/* skip remaining path separators */
do {