Correctly handle rule w/ leading whitespace within a quoted path. Uncomment test case that validates correct behavior.

This commit is contained in:
Brian Cox 2017-03-19 23:09:05 -07:00
parent a2e82147eb
commit 5275975d86
2 changed files with 12 additions and 1 deletions

View File

@ -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<int, int>(std::isspace))));
}
void cFSParserUtil::InterpretFCOName( const std::list<TSTRING>& l, cFCOName& nameOut ) const
{
TSTRING strT;
@ -141,6 +146,12 @@ void cFSParserUtil::InterpretFCOName( const std::list<TSTRING>& 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;
}

View File

@ -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