fix non-quoted resolution of link commands
This commit is contained in:
parent
579a806c64
commit
3dc60ff7e3
3 changed files with 21 additions and 4 deletions
|
|
@ -146,6 +146,7 @@ std::string concatargs(std::vector<std::string> const& args);
|
||||||
int _exec(std::string const& bin, std::vector<std::string> const& args);
|
int _exec(std::string const& bin, std::vector<std::string> const& args);
|
||||||
|
|
||||||
std::string stringReplace(std::string subject, const std::string& search, const std::string& replace);
|
std::string stringReplace(std::string subject, const std::string& search, const std::string& replace);
|
||||||
|
std::string escape_chars(std::string subject, const char* chars);
|
||||||
|
|
||||||
void printFormatError(format_error const& e, bool print_line=true);
|
void printFormatError(format_error const& e, bool print_line=true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -278,13 +278,16 @@ std::pair< std::vector<arg*> , bool > resolve_arg(arg* in, parse_context ctx, bo
|
||||||
if(tsh->quoted || forcequote)
|
if(tsh->quoted || forcequote)
|
||||||
{
|
{
|
||||||
fulltext = stringReplace(fulltext, "\\\"", "\\\\\"");
|
fulltext = stringReplace(fulltext, "\\\"", "\\\\\"");
|
||||||
fulltext = stringReplace(fulltext, "\"", "\\\"");
|
fulltext = escape_chars(fulltext, "\"`$");
|
||||||
fulltext = stringReplace(fulltext, "!", "\"\\!\"");
|
fulltext = stringReplace(fulltext, "!", "\"\\!\"");
|
||||||
fulltext = stringReplace(fulltext, "$", "\\$");
|
|
||||||
fulltext = stringReplace(fulltext, "`", "\\`");
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fulltext = escape_chars(fulltext, "\\\"!$`#&|()';<>");
|
||||||
|
}
|
||||||
|
|
||||||
if(!tsh->quoted && forcequote)
|
if(!tsh->quoted && forcequote)
|
||||||
fulltext = '"' + fulltext + '"';
|
fulltext = '"' + fulltext + '"';
|
||||||
|
|
||||||
|
|
||||||
if(tsh->quoted || forcequote)
|
if(tsh->quoted || forcequote)
|
||||||
|
|
|
||||||
13
src/util.cpp
13
src/util.cpp
|
|
@ -204,6 +204,19 @@ std::string stringReplace(std::string subject, const std::string& search, const
|
||||||
return subject;
|
return subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string escape_chars(std::string subject, const char* chars)
|
||||||
|
{
|
||||||
|
for(size_t i=0; i<subject.size(); i++)
|
||||||
|
{
|
||||||
|
if(is_in(subject[i], chars))
|
||||||
|
{
|
||||||
|
subject.insert(subject.begin()+i, '\\');
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return subject;
|
||||||
|
}
|
||||||
|
|
||||||
std::string repeatString(std::string const& str, uint32_t n)
|
std::string repeatString(std::string const& str, uint32_t n)
|
||||||
{
|
{
|
||||||
std::string ret;
|
std::string ret;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue