Fix escaping of single quote. Closes #307, updates tests.

This commit is contained in:
Sandro Santilli 2013-10-03 13:40:50 +02:00
parent 21f03b3f9e
commit 60030b1e69
3 changed files with 3 additions and 3 deletions

View File

@ -10,7 +10,7 @@ tree.Quoted.prototype = {
toString: function(quotes) {
var xmlvalue = this.value
.replace(/&/g, '&')
.replace(/\'/g, ''')
.replace(/\'/g, '\\\'')
.replace(/\"/g, '"')
.replace(/</g, '&lt;')
.replace(/\>/g, '&gt;');

View File

@ -17,7 +17,7 @@ describe('Quoted', function() {
it('should produce xml-friendly output', function() {
var f = new tree.Quoted("Tom's & \"<quoted>\"");
assert.ok(f);
assert.equal(f.toString(true), "'Tom&apos;s &amp; &quot;&lt;quoted&gt;&quot;'");
assert.equal(f.toString(true), "'Tom\\'s &amp; &quot;&lt;quoted&gt;&quot;'");
});
});
});

View File

@ -5,7 +5,7 @@
<Style name="world" filter-mode="first">
<Rule>
<Filter>([name2] = ' Sa&apos;ad')</Filter>
<Filter>([name2] = ' Sa\'ad')</Filter>
<PolygonSymbolizer fill="#ffffff" />
</Rule>
</Style>