1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 03:17:59 +01:00

Fix some quoting issues.

This commit is contained in:
Kris Maglione
2010-09-24 23:23:26 -04:00
parent 5257be7699
commit 9a73911347
2 changed files with 6 additions and 5 deletions

View File

@@ -1175,23 +1175,23 @@ const Commands = Module("commands", {
Commands.quoteMap = { Commands.quoteMap = {
"\n": "\\n", "\n": "\\n",
"\t": "\\t", "\t": "\\t",
"'": "''"
}; };
function quote(q, list) { function quote(q, list, map) {
map = map || Commands.quoteMap;
let re = RegExp("[" + list + "]", "g"); let re = RegExp("[" + list + "]", "g");
let res = function (str) q + String.replace(str, re, function ($0) $0 in Commands.quoteMap ? Commands.quoteMap[$0] : ("\\" + $0)) + q; let res = function (str) q + String.replace(str, re, function ($0) $0 in map ? map[$0] : ("\\" + $0)) + q;
res.list = list; res.list = list;
return res; return res;
}; };
Commands.complQuote = { Commands.complQuote = {
'"': ['"', quote("", '\n\t"\\\\'), '"'], '"': ['"', quote("", '\n\t"\\\\'), '"'],
"'": ["'", quote("", "'"), "'"], "'": ["'", quote("", "'", { "'": "''" }), "'"],
"": ["", quote("", "\\\\ '\""), ""] "": ["", quote("", "\\\\ '\""), ""]
}; };
Commands.quoteArg = { Commands.quoteArg = {
'"': quote('"', '\n\t"\\\\'), '"': quote('"', '\n\t"\\\\'),
"'": quote("'", "'"), "'": quote("'", "'", { "'": "''" }),
"": quote("", "\\\\\\s'\"") "": quote("", "\\\\\\s'\"")
}; };

View File

@@ -1169,6 +1169,7 @@ const Options = Module("options", {
[option.value, "Current value"], [option.value, "Current value"],
[option.defaultValue, "Default value"] [option.defaultValue, "Default value"]
].filter(function (f) f[0] !== "" && String(f[0]).length < 200); ].filter(function (f) f[0] !== "" && String(f[0]).length < 200);
context.quote = ["", util.identity, ""];
}); });
} }