mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-22 12:21:51 +00:00
escape XML in SVG strings
This commit is contained in:
parent
e5d92f71d5
commit
0ed5f80248
2 changed files with 16 additions and 4 deletions
|
|
@ -328,7 +328,7 @@
|
|||
toFixed(lineTopOffset + (i === 0 ? this._shadowOffsets[j][1] : 0), 2),
|
||||
'" ',
|
||||
this._getFillAttributes(this._shadows[j].color), '>',
|
||||
textLines[i],
|
||||
fabric.util.string.escapeXml(textLines[i]),
|
||||
'</tspan>');
|
||||
lineTopOffsetMultiplier = 1;
|
||||
} else {
|
||||
|
|
@ -355,7 +355,7 @@
|
|||
toFixed(lineTopOffset * lineTopOffsetMultiplier, 2) , '" ',
|
||||
// doing this on <tspan> elements since setting opacity on containing <text> one doesn't work in Illustrator
|
||||
this._getFillAttributes(this.fill), '>',
|
||||
textLines[i],
|
||||
fabric.util.string.escapeXml(textLines[i]),
|
||||
'</tspan>'
|
||||
);
|
||||
lineTopOffsetMultiplier = 1;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
(function() {
|
||||
|
||||
if (!String.prototype.trim) {
|
||||
/**
|
||||
* Trims a string (removing whitespace from the beginning and the end)
|
||||
|
|
@ -34,8 +36,18 @@ function capitalize(string) {
|
|||
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
||||
}
|
||||
|
||||
function escapeXml(string) {
|
||||
return string.replace('&', '&')
|
||||
.replace('"', '"')
|
||||
.replace("'", ''')
|
||||
.replace("<", '<')
|
||||
.replace(">", '>');
|
||||
}
|
||||
|
||||
/** @namespace */
|
||||
fabric.util.string = {
|
||||
camelize: camelize,
|
||||
capitalize: capitalize
|
||||
};
|
||||
capitalize: capitalize,
|
||||
escapeXml: escapeXml
|
||||
};
|
||||
}());
|
||||
|
|
|
|||
Loading…
Reference in a new issue