commit
c45932c6b8
|
@ -292,7 +292,7 @@ function getHTMLFromAtext(pad, atext)
|
||||||
var url = urlData[1];
|
var url = urlData[1];
|
||||||
var urlLength = url.length;
|
var urlLength = url.length;
|
||||||
processNextChars(startIndex - idx);
|
processNextChars(startIndex - idx);
|
||||||
assem.append('<a href="' + url.replace(/\"/g, '"') + '">');
|
assem.append('<a href="' + _escapeHTML(url) + '">');
|
||||||
processNextChars(urlLength);
|
processNextChars(urlLength);
|
||||||
assem.append('</a>');
|
assem.append('</a>');
|
||||||
});
|
});
|
||||||
|
@ -429,14 +429,15 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback)
|
||||||
|
|
||||||
function _escapeHTML(s)
|
function _escapeHTML(s)
|
||||||
{
|
{
|
||||||
var re = /[&<>]/g;
|
var re = /[&"<>]/g;
|
||||||
if (!re.MAP)
|
if (!re.MAP)
|
||||||
{
|
{
|
||||||
// persisted across function calls!
|
// persisted across function calls!
|
||||||
re.MAP = {
|
re.MAP = {
|
||||||
'&': '&',
|
'&': '&',
|
||||||
|
'"': '"',
|
||||||
'<': '<',
|
'<': '<',
|
||||||
'>': '>',
|
'>': '>'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,14 @@ function binarySearchInfinite(expectedLength, func)
|
||||||
|
|
||||||
function htmlPrettyEscape(str)
|
function htmlPrettyEscape(str)
|
||||||
{
|
{
|
||||||
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\r?\n/g, '\\n');
|
return str.replace(/[&"<>]/g, function (c) {
|
||||||
|
return {
|
||||||
|
'&': '&',
|
||||||
|
'"': '"',
|
||||||
|
'<': '<',
|
||||||
|
'>': '>'
|
||||||
|
}[c] || c;
|
||||||
|
}).replace(/\r?\n/g, '\\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof exports !== "undefined")
|
if (typeof exports !== "undefined")
|
||||||
|
|
|
@ -162,7 +162,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
||||||
{
|
{
|
||||||
href = "http://"+href;
|
href = "http://"+href;
|
||||||
}
|
}
|
||||||
extraOpenTags = extraOpenTags + '<a href="' + href.replace(/\"/g, '"') + '">';
|
extraOpenTags = extraOpenTags + '<a href="' + domline.escapeHTML(href) + '">';
|
||||||
extraCloseTags = '</a>' + extraCloseTags;
|
extraCloseTags = '</a>' + extraCloseTags;
|
||||||
}
|
}
|
||||||
if (simpleTags)
|
if (simpleTags)
|
||||||
|
@ -229,7 +229,7 @@ domline.escapeHTML = function(s)
|
||||||
'&': '&',
|
'&': '&',
|
||||||
'<': '<',
|
'<': '<',
|
||||||
'>': '>',
|
'>': '>',
|
||||||
'"': '"',
|
'"': '"',
|
||||||
"'": '''
|
"'": '''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
||||||
{
|
{
|
||||||
if (href)
|
if (href)
|
||||||
{
|
{
|
||||||
extraOpenTags = extraOpenTags + '<a href="' + href.replace(/\"/g, '"') + '">';
|
extraOpenTags = extraOpenTags + '<a href="' + domline.escapeHTML(href) + '">';
|
||||||
extraCloseTags = '</a>' + extraCloseTags;
|
extraCloseTags = '</a>' + extraCloseTags;
|
||||||
}
|
}
|
||||||
if (simpleTags)
|
if (simpleTags)
|
||||||
|
|
|
@ -23,7 +23,14 @@
|
||||||
var padutils = {
|
var padutils = {
|
||||||
escapeHtml: function(x)
|
escapeHtml: function(x)
|
||||||
{
|
{
|
||||||
return String(x).replace(/\</g, '<').replace(/\>/g, '>');
|
return String(x).replace(/[&"<>]/g, function (c) {
|
||||||
|
return {
|
||||||
|
'&': '&',
|
||||||
|
'"': '"',
|
||||||
|
'<': '<',
|
||||||
|
'>': '>'
|
||||||
|
}[c] || c;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
uniqueId: function()
|
uniqueId: function()
|
||||||
{
|
{
|
||||||
|
@ -180,7 +187,7 @@ var padutils = {
|
||||||
var startIndex = urls[j][0];
|
var startIndex = urls[j][0];
|
||||||
var href = urls[j][1];
|
var href = urls[j][1];
|
||||||
advanceTo(startIndex);
|
advanceTo(startIndex);
|
||||||
pieces.push('<a ', (target ? 'target="' + target + '" ' : ''), 'href="', href.replace(/\"/g, '"'), '">');
|
pieces.push('<a ', (target ? 'target="' + target + '" ' : ''), 'href="', padutils.escapeHtml(href), '">');
|
||||||
advanceTo(startIndex + href.length);
|
advanceTo(startIndex + href.length);
|
||||||
pieces.push('</a>');
|
pieces.push('</a>');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue