Fix issue 1174 reported by psh.tnt re: XML entity escaping (within attributes); updated test as well
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2696 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
d6cc464ba5
commit
f18cdbbeae
|
@ -55,7 +55,9 @@ svgedit.utilities.init = function(editorContext) {
|
||||||
// Returns:
|
// Returns:
|
||||||
// The converted string
|
// The converted string
|
||||||
svgedit.utilities.toXml = function(str) {
|
svgedit.utilities.toXml = function(str) {
|
||||||
return $('<p/>').text(str).html();
|
// ' is ok in XML, but not HTML
|
||||||
|
// > does not normally need escaping, though it can if within a CDATA expression (and preceded by "]]")
|
||||||
|
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/, ''');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function: svgedit.utilities.fromXml
|
// Function: svgedit.utilities.fromXml
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
equals(toXml('PB&J'), 'PB&J');
|
equals(toXml('PB&J'), 'PB&J');
|
||||||
equals(toXml('2 < 5'), '2 < 5');
|
equals(toXml('2 < 5'), '2 < 5');
|
||||||
equals(toXml('5 > 2'), '5 > 2');
|
equals(toXml('5 > 2'), '5 > 2');
|
||||||
equals(toXml('\'<&>"'), '\'<&>"');
|
equals(toXml('\'<&>"'), ''<&>"');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Test svgedit.utilities.fromXml() function', function() {
|
test('Test svgedit.utilities.fromXml() function', function() {
|
||||||
|
|
Loading…
Reference in New Issue