Skip to content

Commit 629550b

Browse files
committed
path_utils: Strip trailing path separators
Path may well end with a '/', e.g. URLs. So strip them away since otherwise mp_basename finds the wrong part of the given path. In case of the 'filename' property this simply results in it being set to the whole URL. But in case of the %f/%F screenshot-template specifiers it may result in a broken screenshot path, if %f occurs before the first '/'.
1 parent 28ef6b7 commit 629550b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

misc/path_utils.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ char *mp_basename(const char *path)
4343
{
4444
char *s;
4545

46+
/* otherwise the check below finds the wrong index */
47+
mp_path_strip_trailing_separator((char *)path);
48+
4649
#if HAVE_DOS_PATHS
4750
if (!mp_is_url(bstr0(path))) {
4851
s = strrchr(path, '\\');

0 commit comments

Comments
 (0)