mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-06 02:42:33 +01:00
This commit is contained in:
parent
756288294d
commit
ec8e1cca15
@ -79,16 +79,27 @@ var safeTextToTagNode = function(text) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var safeTextToTextNode = function(text) {
|
var safeTextToTextNode = (function() {
|
||||||
// TODO: remove once no more HTML entities in translation files.
|
let entities = new Map([
|
||||||
|
// TODO: Remove quote entities once no longer present in translation
|
||||||
|
// files. Other entities must stay.
|
||||||
|
[ '“', '“' ],
|
||||||
|
[ '”', '”' ],
|
||||||
|
[ '‘', '‘' ],
|
||||||
|
[ '’', '’' ],
|
||||||
|
[ '<', '<' ],
|
||||||
|
[ '>', '>' ],
|
||||||
|
]);
|
||||||
|
let decodeEntities = match => {
|
||||||
|
return entities.get(match) || match;
|
||||||
|
};
|
||||||
|
return function(text) {
|
||||||
if ( text.indexOf('&') !== -1 ) {
|
if ( text.indexOf('&') !== -1 ) {
|
||||||
text = text.replace(/“/g, '“')
|
text = text.replace(/&[a-z]+;/g, decodeEntities);
|
||||||
.replace(/”/g, '”')
|
|
||||||
.replace(/‘/g, '‘')
|
|
||||||
.replace(/’/g, '’');
|
|
||||||
}
|
}
|
||||||
return document.createTextNode(text);
|
return document.createTextNode(text);
|
||||||
};
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
var safeTextToDOM = function(text, parent) {
|
var safeTextToDOM = function(text, parent) {
|
||||||
if ( text === '' ) { return; }
|
if ( text === '' ) { return; }
|
||||||
|
Loading…
Reference in New Issue
Block a user