mirror of
https://gitlab.com/niansa/anyproc.git
synced 2025-03-06 20:49:24 +01:00
Another unescaping fix
This commit is contained in:
parent
5c66ef1c18
commit
0a2dee3a2e
1 changed files with 3 additions and 2 deletions
|
@ -26,15 +26,16 @@ public:
|
|||
return fres;
|
||||
}
|
||||
static inline const std::string unescape(std::string_view str) {
|
||||
unsigned backTruncateCount = 0;
|
||||
while (*(str.end()-backTruncateCount-1) == ' ') backTruncateCount++;
|
||||
const char quotes = str[0];
|
||||
if (quotes != '"' && quotes != '\'') {
|
||||
return std::string(str);
|
||||
}
|
||||
std::string fres;
|
||||
for (const char c : std::string_view{str.data()+1, str.size()-2}) {
|
||||
for (const char c : std::string_view{str.data()+1, str.size()-2-backTruncateCount}) {
|
||||
if (c != '\\') fres.push_back(c);
|
||||
}
|
||||
while (fres.back() == quotes) fres.pop_back();
|
||||
return fres;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue