mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-05 18:32:30 +01:00
This commit is contained in:
parent
756288294d
commit
ec8e1cca15
@ -79,16 +79,27 @@ var safeTextToTagNode = function(text) {
|
||||
}
|
||||
};
|
||||
|
||||
var safeTextToTextNode = function(text) {
|
||||
// TODO: remove once no more HTML entities in translation files.
|
||||
if ( text.indexOf('&') !== -1 ) {
|
||||
text = text.replace(/“/g, '“')
|
||||
.replace(/”/g, '”')
|
||||
.replace(/‘/g, '‘')
|
||||
.replace(/’/g, '’');
|
||||
}
|
||||
return document.createTextNode(text);
|
||||
};
|
||||
var safeTextToTextNode = (function() {
|
||||
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 ) {
|
||||
text = text.replace(/&[a-z]+;/g, decodeEntities);
|
||||
}
|
||||
return document.createTextNode(text);
|
||||
};
|
||||
})();
|
||||
|
||||
var safeTextToDOM = function(text, parent) {
|
||||
if ( text === '' ) { return; }
|
||||
|
Loading…
Reference in New Issue
Block a user