diff --git a/src/fs/fsparserutil.cpp b/src/fs/fsparserutil.cpp index c20ed44..c711234 100644 --- a/src/fs/fsparserutil.cpp +++ b/src/fs/fsparserutil.cpp @@ -131,6 +131,11 @@ void cFSParserUtil::AddSubTypeProps( cFCOPropVector& v ) const v.AddItemAndGrow( cFSPropSet::PROP_FILETYPE ); } +static inline void trim_leading_whitespace(std::string &str) +{ + str.erase(str.begin(), std::find_if(str.begin(), str.end(), std::not1(std::ptr_fun(std::isspace)))); +} + void cFSParserUtil::InterpretFCOName( const std::list& l, cFCOName& nameOut ) const { TSTRING strT; @@ -141,6 +146,12 @@ void cFSParserUtil::InterpretFCOName( const std::list& l, cFCOName& nam strT = cDevicePath::AsPosix(strT); #endif + //Trim any remaining whitespace before actual path, for cases like " /foo", + // otherwise it'll be flagged as a relative path. + //Don't trim trailing whitespace, since that could potentially be a valid path. + if(strT[0] != '/') + trim_leading_whitespace(strT); + // let cFCOName handle interpretation nameOut = strT; } diff --git a/src/parser/testfiles/polhard.txt b/src/parser/testfiles/polhard.txt index fad96b8..6d3f7cd 100644 --- a/src/parser/testfiles/polhard.txt +++ b/src/parser/testfiles/polhard.txt @@ -18,7 +18,7 @@ FOO = ping; # test quoted strings "/qfoo" -> +p ; "/Program Files" -> +p ; -#" /lots o' spaces " -> +p ; +" /lots o' spaces " -> +p ; #" colon: semicolon; quote' " -> +p ; # test attributes