Merge pull request #3040 from CatoTH/Issue3024-Escaping-of-HTML-elements
Bugfix for #3024 - escaping HTML tags
This commit is contained in:
commit
a33d504c6b
@ -172,7 +172,7 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
||||
|
||||
this._serializeDom = function(node, stripLineNumbers) {
|
||||
if (node.nodeType == TEXT_NODE) {
|
||||
return node.nodeValue;
|
||||
return node.nodeValue.replace(/</g, "<").replace(/>/g, ">");
|
||||
}
|
||||
if (stripLineNumbers && (
|
||||
lineNumberingService._isOsLineNumberNode(node) || lineNumberingService._isOsLineBreakNode(node))) {
|
||||
@ -193,7 +193,7 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
||||
var html = this._serializeTag(node);
|
||||
for (var i = 0; i < node.childNodes.length; i++) {
|
||||
if (node.childNodes[i].nodeType == TEXT_NODE) {
|
||||
html += node.childNodes[i].nodeValue;
|
||||
html += node.childNodes[i].nodeValue.replace(/</g, "<").replace(/>/g, ">");
|
||||
} else if (!stripLineNumbers || (!lineNumberingService._isOsLineNumberNode(node.childNodes[i]) && !lineNumberingService._isOsLineBreakNode(node.childNodes[i]))) {
|
||||
html += this._serializeDom(node.childNodes[i], stripLineNumbers);
|
||||
}
|
||||
|
@ -188,6 +188,12 @@ describe('linenumbering', function () {
|
||||
expect(diff.outerContextStart).toBe('<OL start="3">');
|
||||
expect(diff.outerContextEnd).toBe('</OL>');
|
||||
});
|
||||
|
||||
it('escapes text resembling HTML-Tags', function () {
|
||||
var inHtml = '<h2>' + noMarkup(1) + 'Looks like a <p> tag </p></h2><p>' + noMarkup(2) + 'Another line</p>';
|
||||
var diff = diffService.extractRangeByLineNumbers(inHtml, 1, 2, true);
|
||||
expect(diff.html).toBe('<H2>Looks like a <p> tag </p></H2>');
|
||||
});
|
||||
});
|
||||
|
||||
describe('merging two sections', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user