Allow having semi-colons in quoted arguments in the cmd part of mimeview defs
This commit is contained in:
@@ -905,11 +905,17 @@ bool RclConfig::getGuiFilter(const string& catfiltername, string& frag) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RclConfig::valueSplitAttributes(const string& whole, string& value,
|
||||
ConfSimple& attrs)
|
||||
bool RclConfig::valueSplitAttributes(const string& whole, string& value, ConfSimple& attrs)
|
||||
{
|
||||
/* There is currently no way to escape a semi-colon */
|
||||
string::size_type semicol0 = whole.find_first_of(";");
|
||||
bool inquote{false};
|
||||
string::size_type semicol0;
|
||||
for (semicol0 = 0; semicol0 < whole.size(); semicol0++) {
|
||||
if (whole[semicol0] == '"') {
|
||||
inquote = !inquote;
|
||||
} else if (whole[semicol0] == ';' && !inquote) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
value = whole.substr(0, semicol0);
|
||||
trimstring(value);
|
||||
string attrstr;
|
||||
|
||||
+10
-4
@@ -259,12 +259,18 @@ public:
|
||||
string getMimeHandlerDef(const string &mimetype, bool filtertypes=false,
|
||||
const std::string& fn = std::string());
|
||||
|
||||
/** For lines like: "name = some value; attr1 = value1; attr2 = val2"
|
||||
/** For lines like: [name = some value; attr1 = value1; attr2 = val2]
|
||||
* Separate the value and store the attributes in a ConfSimple
|
||||
* @param whole the raw value. No way to escape a semi-colon in there.
|
||||
*
|
||||
* In the value part, semi-colons inside double quotes are ignored, and double quotes are
|
||||
* conserved. In the common case where the string is then processed by stringToStrings() to
|
||||
* build a command line, this allows having semi-colons inside arguments. However, no backslash
|
||||
* escaping is possible, so that, for example "bla\"1;2\"" would not work (the value part
|
||||
* would stop at the semi-colon).
|
||||
*
|
||||
* @param whole the raw value.
|
||||
*/
|
||||
static bool valueSplitAttributes(const string& whole, string& value,
|
||||
ConfSimple& attrs) ;
|
||||
static bool valueSplitAttributes(const string& whole, string& value, ConfSimple& attrs) ;
|
||||
|
||||
/** Compute difference between 'base' and 'changed', as elements to be
|
||||
* added and substracted from base. Input and output strings are in
|
||||
|
||||
Reference in New Issue
Block a user