Escape Ampersands - fixes #3563
This commit is contained in:
parent
3ddc73b0a0
commit
a345815b57
@ -185,17 +185,17 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
||||
};
|
||||
|
||||
this._serializeDom = function(node, stripLineNumbers) {
|
||||
if (node.nodeType == TEXT_NODE) {
|
||||
if (node.nodeType === TEXT_NODE) {
|
||||
return node.nodeValue.replace(/</g, "<").replace(/>/g, ">");
|
||||
}
|
||||
if (stripLineNumbers && (
|
||||
lineNumberingService._isOsLineNumberNode(node) || lineNumberingService._isOsLineBreakNode(node))) {
|
||||
return '';
|
||||
}
|
||||
if (node.nodeName == 'OS-LINEBREAK') {
|
||||
if (node.nodeName === 'OS-LINEBREAK') {
|
||||
return '';
|
||||
}
|
||||
if (node.nodeName == 'BR') {
|
||||
if (node.nodeName === 'BR') {
|
||||
var br = '<BR';
|
||||
for (i = 0; i < node.attributes.length; i++) {
|
||||
var attr = node.attributes[i];
|
||||
@ -206,13 +206,13 @@ 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.replace(/</g, "<").replace(/>/g, ">");
|
||||
if (node.childNodes[i].nodeType === TEXT_NODE) {
|
||||
html += node.childNodes[i].nodeValue.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||
} else if (!stripLineNumbers || (!lineNumberingService._isOsLineNumberNode(node.childNodes[i]) && !lineNumberingService._isOsLineBreakNode(node.childNodes[i]))) {
|
||||
html += this._serializeDom(node.childNodes[i], stripLineNumbers);
|
||||
}
|
||||
}
|
||||
if (node.nodeType != DOCUMENT_FRAGMENT_NODE) {
|
||||
if (node.nodeType !== DOCUMENT_FRAGMENT_NODE) {
|
||||
html += '</' + node.nodeName + '>';
|
||||
}
|
||||
|
||||
|
@ -300,6 +300,13 @@ describe('linenumbering', function () {
|
||||
expect(containsError).toBe(-1);
|
||||
expect(containsCorrectVersion > 0).toBe(true);
|
||||
});
|
||||
|
||||
it('keeps ampersands escaped', function() {
|
||||
var pre = '<p>' + noMarkup(1) + 'foo & bar</p>',
|
||||
after = '<p>' + noMarkup(1) + 'foo & bar ins</p>';
|
||||
var merged = diffService.replaceLines(pre, after, 1, 2, true);
|
||||
expect(merged).toBe('<P>foo & bar ins</P>');
|
||||
});
|
||||
});
|
||||
|
||||
describe('detecting the type of change', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user