mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2025-10-17 22:11:01 +02:00
Fix a potential double-unescaping issue, tweak 'App.escapeHtml()'.
This commit is contained in:
parent
26f1f67746
commit
b888fa1032
40
js/App.js
40
js/App.js
@ -411,19 +411,35 @@ const App = {
|
||||
},
|
||||
// htmlspecialchars()-alike for headlines data-content attribute
|
||||
escapeHtml: function(p) {
|
||||
if (typeof p == "string") {
|
||||
const map = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": '''
|
||||
};
|
||||
|
||||
return p.replace(/[&<>"']/g, function(m) { return map[m]; });
|
||||
} else {
|
||||
if (typeof p !== 'string')
|
||||
return p;
|
||||
}
|
||||
|
||||
const map = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'/': '/',
|
||||
};
|
||||
|
||||
return p.replace(/[&<>"'\/]/g, m => map[m]);
|
||||
},
|
||||
unescapeHtml: function(p) {
|
||||
if (typeof p !== 'string' || p.indexOf('&') === -1)
|
||||
return p;
|
||||
|
||||
return p.replace(/&(?:amp|lt|gt|quot|#x27|#x2F|#039|#47);/g, function(entity) {
|
||||
switch (entity) {
|
||||
case '&': return '&';
|
||||
case '<': return '<';
|
||||
case '>': return '>';
|
||||
case '"': return '"';
|
||||
case ''': case ''': return "'";
|
||||
case '/': case '/': return '/';
|
||||
default: return entity;
|
||||
}
|
||||
});
|
||||
},
|
||||
// http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac
|
||||
getSelectedText: function() {
|
||||
|
@ -237,16 +237,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
|
||||
return rc;
|
||||
},
|
||||
getLabel: function(item) {
|
||||
let name = String(item.name);
|
||||
|
||||
/* Horrible */
|
||||
name = name.replace(/"/g, "\"");
|
||||
name = name.replace(/&/g, "&");
|
||||
name = name.replace(/—/g, "-");
|
||||
name = name.replace(/</g, "<");
|
||||
name = name.replace(/>/g, ">");
|
||||
|
||||
return name;
|
||||
return App.unescapeHtml(item.name);
|
||||
},
|
||||
expandParentNodes: function(feed, is_cat, list) {
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user