Escape backslash in domain parser

Backslash is the escape key so it must be escaped.

issue4471
review6041002
This commit is contained in:
C?dric Krier 2015-02-19 13:44:24 +01:00
parent cc335e75e5
commit 7ad8438017
2 changed files with 5 additions and 1 deletions

View file

@ -1180,6 +1180,9 @@
if (typeof value != 'string') {
return value;
}
if (value.contains('\\')) {
value = value.replace(new RegExp('\\\\', 'g'), '\\\\');
}
if (value.contains('"')) {
value = value.replace(new RegExp('"', 'g'), '\\"');
}

View file

@ -1014,7 +1014,8 @@
[
['test', 'test'],
['foo bar', '"foo bar"'],
['"foo"', '\\\"foo\\\"']
['"foo"', '\\\"foo\\\"'],
['foo\\bar', 'foo\\\\bar']
].forEach(function(test) {
var value = test[0];
var result = test[1];