mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Bug #581
- Applied patch to fix bug #581, in which backslashes in annotations and descriptions caused problems (thanks to Itay Perl). - Corrected unit tests that were shown to be incorrect, after the patch corrected other behavior.
This commit is contained in:
parent
1d4c79b897
commit
595dd9f3f4
5 changed files with 48 additions and 61 deletions
|
@ -41,6 +41,8 @@
|
||||||
(thanks to Itay Perl).
|
(thanks to Itay Perl).
|
||||||
+ Fixed bug #579, which displayed incorrect counts when using the 'limit:N'
|
+ Fixed bug #579, which displayed incorrect counts when using the 'limit:N'
|
||||||
filter (thanks to Thomas Sattler).
|
filter (thanks to Thomas Sattler).
|
||||||
|
+ Applied patch to fix bug #581, in which backslashes in annotations and
|
||||||
|
descriptions caused problems (thanks to Itay Perl).
|
||||||
|
|
||||||
------ old releases ------------------------------
|
------ old releases ------------------------------
|
||||||
|
|
||||||
|
|
|
@ -213,66 +213,51 @@ bool Nibbler::getUntilEOS (std::string& result)
|
||||||
bool Nibbler::getQuoted (
|
bool Nibbler::getQuoted (
|
||||||
char c,
|
char c,
|
||||||
std::string& result,
|
std::string& result,
|
||||||
bool unescape /* = true */,
|
|
||||||
bool quote /* = false */)
|
bool quote /* = false */)
|
||||||
{
|
{
|
||||||
if (mCursor < mLength)
|
bool inquote = false;
|
||||||
|
bool inescape = false;
|
||||||
|
char current = 0;
|
||||||
|
char previous = 0;
|
||||||
|
result = "";
|
||||||
|
|
||||||
|
if (mCursor >= mLength ||
|
||||||
|
mInput[mCursor] != c)
|
||||||
{
|
{
|
||||||
if (mInput[mCursor] != c)
|
return false;
|
||||||
return false;
|
}
|
||||||
|
|
||||||
result = "";
|
for (std::string::size_type i = mCursor; i < mLength; ++i)
|
||||||
bool inquote = false;
|
{
|
||||||
char current = 0;
|
previous = current;
|
||||||
char previous = 0;
|
current = mInput[i];
|
||||||
|
|
||||||
// '"'
|
if (current == '\\' && !inescape)
|
||||||
// p c
|
|
||||||
// - -
|
|
||||||
// '
|
|
||||||
// ' "
|
|
||||||
// " '
|
|
||||||
for (std::string::size_type i = mCursor; i < mLength; ++i)
|
|
||||||
{
|
{
|
||||||
previous = current;
|
inescape = true;
|
||||||
current = mInput[i];
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (current == c)
|
if (current == c && !inescape)
|
||||||
|
{
|
||||||
|
if (quote)
|
||||||
|
result += current;
|
||||||
|
|
||||||
|
if (!inquote)
|
||||||
{
|
{
|
||||||
if (previous == '\\')
|
inquote = true;
|
||||||
{
|
|
||||||
if (!unescape)
|
|
||||||
result += previous;
|
|
||||||
|
|
||||||
result += current;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!inquote)
|
|
||||||
{
|
|
||||||
inquote = true;
|
|
||||||
if (quote)
|
|
||||||
result += current;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (quote)
|
|
||||||
result += current;
|
|
||||||
|
|
||||||
mCursor = i + 1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (current == '\\')
|
|
||||||
{
|
|
||||||
// NOP
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result += current;
|
mCursor = i + 1;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += current;
|
||||||
|
inescape = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
bool getUntilEOL (std::string&);
|
bool getUntilEOL (std::string&);
|
||||||
bool getUntilEOS (std::string&);
|
bool getUntilEOS (std::string&);
|
||||||
|
|
||||||
bool getQuoted (char, std::string&, bool unescape = true, bool quote = false);
|
bool getQuoted (char, std::string&, bool quote = false);
|
||||||
bool getInt (int&);
|
bool getInt (int&);
|
||||||
bool getUnsignedInt (int&);
|
bool getUnsignedInt (int&);
|
||||||
bool getNumber (double&);
|
bool getNumber (double&);
|
||||||
|
|
|
@ -258,13 +258,13 @@ int main (int argc, char** argv)
|
||||||
|
|
||||||
n = Nibbler ("name:\""\"");
|
n = Nibbler ("name:\""\"");
|
||||||
a7.parse (n);
|
a7.parse (n);
|
||||||
t.is (a7.composeF4 (), "name:\"&dquot;\"",
|
t.is (a7.composeF4 (), "name:\"'\"",
|
||||||
"Att::parse (name:\""\")");
|
"Att::parse (name:\"'\")");
|
||||||
|
|
||||||
n = Nibbler ("name:\"&tab;",&open;&close;:\"");
|
n = Nibbler ("name:\"&tab;",&open;&close;:\"");
|
||||||
a7.parse (n);
|
a7.parse (n);
|
||||||
t.is (a7.composeF4 (), "name:\"&tab;&dquot;,&open;&close;:\"",
|
t.is (a7.composeF4 (), "name:\"&tab;',&open;&close;:\"",
|
||||||
"Att::parse (name:\"&tab;",&open;&close;:\")");
|
"Att::parse (name:\"&tab;',&open;&close;:\")");
|
||||||
|
|
||||||
n = Nibbler ("total gibberish");
|
n = Nibbler ("total gibberish");
|
||||||
good = true;
|
good = true;
|
||||||
|
|
|
@ -190,23 +190,23 @@ int main (int argc, char** argv)
|
||||||
t.notok (n.getQuoted ('\'', s), " 'x' : getQuoted (''') -> false");
|
t.notok (n.getQuoted ('\'', s), " 'x' : getQuoted (''') -> false");
|
||||||
|
|
||||||
n = Nibbler ("\"one\\\"two\"");
|
n = Nibbler ("\"one\\\"two\"");
|
||||||
t.notok (n.getQuoted ('\'', s), "\"one\\\"two\" : getQuoted (''') -> false"); // 86
|
t.notok (n.getQuoted ('\'', s), "\"one\\\"two\" : getQuoted (''') -> false"); // 86
|
||||||
|
|
||||||
n = Nibbler ("\"one\\\"two\"");
|
n = Nibbler ("\"one\\\"two\"");
|
||||||
t.ok (n.getQuoted ('"', s, false, false), "\"one\\\"two\" : getQuoted ('\"', false, false) -> true"); // 87
|
t.ok (n.getQuoted ('"', s, false), "\"one\\\"two\" : getQuoted ('\"', false, false) -> true"); // 87
|
||||||
t.is (s, "one\\\"two", "getQuoted ('\"', false, false) -> one\\\"two"); // 88
|
t.is (s, "one\"two", "getQuoted ('\"', false) -> one\"two"); // 88
|
||||||
|
|
||||||
n = Nibbler ("\"one\\\"two\"");
|
n = Nibbler ("\"one\\\"two\"");
|
||||||
t.ok (n.getQuoted ('"', s, false, true), "\"one\\\"two\" : getQuoted ('\"', false, true) -> true"); // 89
|
t.ok (n.getQuoted ('"', s, true), "\"one\\\"two\" : getQuoted ('\"', false, true) -> true"); // 89
|
||||||
t.is (s, "\"one\\\"two\"", "getQuoted ('\"', false, true) -> \"one\\\"two\""); // 90
|
t.is (s, "\"one\"two\"", "getQuoted ('\"', true) -> \"one\"two\""); // 90
|
||||||
|
|
||||||
n = Nibbler ("\"one\\\"two\"");
|
n = Nibbler ("\"one\\\"two\"");
|
||||||
t.ok (n.getQuoted ('"', s, true, false), "\"one\\\"two\" : getQuoted ('\"', true, false) -> true"); // 91
|
t.ok (n.getQuoted ('"', s, false), "\"one\\\"two\" : getQuoted ('\"', true, false) -> true"); // 91
|
||||||
t.is (s, "one\"two", "getQuoted ('\"', true, false) -> one\"two"); // 92
|
t.is (s, "one\"two", "getQuoted ('\"', false) -> one\"two"); // 92
|
||||||
|
|
||||||
n = Nibbler ("\"one\\\"two\"");
|
n = Nibbler ("\"one\\\"two\"");
|
||||||
t.ok (n.getQuoted ('"', s, true, true), "\"one\\\"two\" : getQuoted ('\"', true, true) -> true"); // 93
|
t.ok (n.getQuoted ('"', s, true), "\"one\\\"two\" : getQuoted ('\"', true, true) -> true"); // 93
|
||||||
t.is (s, "\"one\"two\"", "getQuoted ('\"', true, true) -> \"one\"two\""); // 94
|
t.is (s, "\"one\"two\"", "getQuoted ('\"', true) -> \"one\"two\""); // 94
|
||||||
|
|
||||||
|
|
||||||
// bool getInt (int&);
|
// bool getInt (int&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue