mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
path_make_canonical mishandles empty string.
Fixes https://github.com/ridiculousfish/fishfish/issues/26
This commit is contained in:
parent
457e6a5f46
commit
cc90f9cf80
2 changed files with 10 additions and 3 deletions
|
@ -576,7 +576,14 @@ static void test_path()
|
||||||
if( canon != L"/foo/bar" )
|
if( canon != L"/foo/bar" )
|
||||||
{
|
{
|
||||||
err( L"Bug in canonical PATH code" );
|
err( L"Bug in canonical PATH code" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path = L"/";
|
||||||
|
path_make_canonical(path);
|
||||||
|
if (path != L"/")
|
||||||
|
{
|
||||||
|
err( L"Bug in canonical PATH code" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test is_potential_path */
|
/** Test is_potential_path */
|
||||||
|
|
4
path.cpp
4
path.cpp
|
@ -525,8 +525,8 @@ void path_make_canonical( wcstring &path )
|
||||||
replace_all(path, L"//", L"/");
|
replace_all(path, L"//", L"/");
|
||||||
} while (path.size() != size);
|
} while (path.size() != size);
|
||||||
|
|
||||||
/* Remove trailing slashes */
|
/* Remove trailing slashes, except don't remove the first one */
|
||||||
while (size--) {
|
while (size-- > 1) {
|
||||||
if (path.at(size) != L'/')
|
if (path.at(size) != L'/')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue