diff --git a/src/common.js b/src/common.js index 007da413a6..fb5449b667 100644 --- a/src/common.js +++ b/src/common.js @@ -1003,6 +1003,9 @@ if (typeof value != 'string') { return value; } + if (value.contains('"')) { + value = value.replace(new RegExp('"', 'g'), '\\"'); + } var tests = [':', ' ', '(', ')'].concat(this.OPERATORS); for (var i = 0; i < tests.length; i++) { var test = tests[i]; diff --git a/tests/sao.js b/tests/sao.js index c1ce397b4d..47c3830d8b 100644 --- a/tests/sao.js +++ b/tests/sao.js @@ -919,6 +919,9 @@ ['Name: = Name: Doe', [ ['Name', '=', null], ['Name', null, 'Doe'] + ]], + ['Name: \\"foo\\"', [ + ['Name', null, '"foo"'] ]] ].forEach(function(test) { var value = test[0]; @@ -966,6 +969,21 @@ }); }); + QUnit.test('DomainParser.quote', function() { + var parser = new Sao.common.DomainParser(); + + [ + ['test', 'test'], + ['foo bar', '"foo bar"'], + ['"foo"', '\\\"foo\\\"'] + ].forEach(function(test) { + var value = test[0]; + var result = test[1]; + QUnit.ok(Sao.common.compare(parser.quote(value), result), + 'quote(' + JSON.stringify(value) + ')'); + }); + }); + QUnit.test('DomainParser.split_target_value', function() { var parser = new Sao.common.DomainParser();