mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-25 21:27:19 +02:00
Fixed bug with double escaped single quotes
Before, the parser always escaped single quotes, independent of the quotes being escaped already. This is now fixed.
This commit is contained in:
parent
d270ef31a4
commit
0523ada9fc
2 changed files with 14 additions and 2 deletions
14
src/CLI2.cpp
14
src/CLI2.cpp
|
@ -417,8 +417,18 @@ void CLI2::lexArguments ()
|
|||
else
|
||||
{
|
||||
std::string quote = "'";
|
||||
std::string escaped = _original_args[i].attribute ("raw");
|
||||
escaped = str_replace (escaped, quote, "\\'");
|
||||
// Escape unescaped single quotes
|
||||
std::string escaped = "";
|
||||
bool nextEscaped = false;
|
||||
for(auto c : _original_args[i].attribute ("raw")) {
|
||||
if(!nextEscaped && (c == '\\')) {
|
||||
nextEscaped = true;
|
||||
} else {
|
||||
if(c == '\'' && !nextEscaped) escaped += "\\";
|
||||
nextEscaped = false;
|
||||
}
|
||||
escaped += c;
|
||||
}
|
||||
|
||||
std::string::size_type cursor = 0;
|
||||
std::string word;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue