mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
FF4
- Removed encodings for ',' -> ',', ''' -> '&squot;', and ':' -> '&colon'. - Retained decodings to provide backward compatibility.
This commit is contained in:
parent
fbe24b3fda
commit
ba87499eca
2 changed files with 22 additions and 27 deletions
43
src/Att.cpp
43
src/Att.cpp
|
@ -744,12 +744,12 @@ void Att::dequote (std::string& value) const
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Encode values prior to serialization.
|
||||
// \t -> &tab;
|
||||
// ' -> &squot;
|
||||
// ' -> &squot; <-- deprecated, no need to encode/decod single quotes.
|
||||
// " -> &dquot;
|
||||
// , -> ,
|
||||
// , -> , <-- deprecated, no need to encode/decode commas.
|
||||
// [ -> &open;
|
||||
// ] -> &close;
|
||||
// : -> :
|
||||
// : -> : <-- deprecated, no need to encode/decode colons.
|
||||
void Att::encode (std::string& value) const
|
||||
{
|
||||
std::string::size_type i;
|
||||
|
@ -757,23 +757,14 @@ void Att::encode (std::string& value) const
|
|||
while ((i = value.find ('\t')) != std::string::npos)
|
||||
value.replace (i, 1, "&tab;"); // no i18n
|
||||
|
||||
while ((i = value.find ('\'')) != std::string::npos)
|
||||
value.replace (i, 1, "&squot;"); // no i18n
|
||||
|
||||
while ((i = value.find ('"')) != std::string::npos)
|
||||
value.replace (i, 1, "&dquot;"); // no i18n
|
||||
|
||||
while ((i = value.find (',')) != std::string::npos)
|
||||
value.replace (i, 1, ","); // no i18n
|
||||
|
||||
while ((i = value.find ('[')) != std::string::npos)
|
||||
value.replace (i, 1, "&open;"); // no i18n
|
||||
|
||||
while ((i = value.find (']')) != std::string::npos)
|
||||
value.replace (i, 1, "&close;"); // no i18n
|
||||
|
||||
while ((i = value.find (':')) != std::string::npos)
|
||||
value.replace (i, 1, ":"); // no i18n
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -789,28 +780,32 @@ void Att::decode (std::string& value) const
|
|||
{
|
||||
std::string::size_type i;
|
||||
|
||||
while ((i = value.find ("&tab;")) != std::string::npos) // no i18n
|
||||
// Supported encodings.
|
||||
while ((i = value.find ("&tab;")) != std::string::npos)
|
||||
value.replace (i, 5, "\t");
|
||||
|
||||
while ((i = value.find ("&dquot;")) != std::string::npos) // no i18n
|
||||
while ((i = value.find ("&dquot;")) != std::string::npos)
|
||||
value.replace (i, 7, "\"");
|
||||
|
||||
while ((i = value.find ("&squot;")) != std::string::npos) // no i18n
|
||||
value.replace (i, 7, "'");
|
||||
|
||||
while ((i = value.find (""")) != std::string::npos) // no i18n
|
||||
while ((i = value.find (""")) != std::string::npos)
|
||||
value.replace (i, 6, "\"");
|
||||
|
||||
while ((i = value.find (",")) != std::string::npos) // no i18n
|
||||
value.replace (i, 7, ",");
|
||||
|
||||
while ((i = value.find ("&open;")) != std::string::npos) // no i18n
|
||||
while ((i = value.find ("&open;")) != std::string::npos)
|
||||
value.replace (i, 6, "[");
|
||||
|
||||
while ((i = value.find ("&close;")) != std::string::npos) // no i18n
|
||||
while ((i = value.find ("&close;")) != std::string::npos)
|
||||
value.replace (i, 7, "]");
|
||||
|
||||
while ((i = value.find (":")) != std::string::npos) // no i18n
|
||||
// Support for deprecated encodings. These cannot be removed or old files
|
||||
// will not be parsable. Not just old files - completed.data can contain
|
||||
// tasks formatted/encoded using these.
|
||||
while ((i = value.find ("&squot;")) != std::string::npos)
|
||||
value.replace (i, 7, "'");
|
||||
|
||||
while ((i = value.find (",")) != std::string::npos)
|
||||
value.replace (i, 7, ",");
|
||||
|
||||
while ((i = value.find (":")) != std::string::npos)
|
||||
value.replace (i, 7, ":");
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ int main (int argc, char** argv)
|
|||
a5.value ("\"");
|
||||
t.is (a5.composeF4 (), "name:\"&dquot;\"", "Att::composeF4 encoded \"");
|
||||
a5.value ("\t\",[]:");
|
||||
t.is (a5.composeF4 (), "name:\"&tab;&dquot;,&open;&close;:\"", "Att::composeF4 fully encoded \\t\",[]:");
|
||||
t.is (a5.composeF4 (), "name:\"&tab;&dquot;,&open;&close;:\"", "Att::composeF4 fully encoded \\t\",[]:");
|
||||
|
||||
Att a6 ("name", 6);
|
||||
t.is (a6.value_int (), 6, "Att::value_int get");
|
||||
|
@ -187,8 +187,8 @@ int main (int argc, char** argv)
|
|||
|
||||
n = Nibbler ("name:\"&tab;",&open;&close;:\"");
|
||||
a7.parse (n);
|
||||
t.is (a7.composeF4 (), "name:\"&tab;&dquot;,&open;&close;:\"",
|
||||
"Att::parse (name:\"&tab;",&open;&close;:\")");
|
||||
t.is (a7.composeF4 (), "name:\"&tab;&dquot;,&open;&close;:\"",
|
||||
"Att::parse (name:\"&tab;",&open;&close;:\")");
|
||||
|
||||
n = Nibbler ("total gibberish");
|
||||
good = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue