mirror of https://github.com/gorhill/uBlock.git
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([
|
||||||
if ( text.indexOf('&') !== -1 ) {
|
// TODO: Remove quote entities once no longer present in translation
|
||||||
text = text.replace(/“/g, '“')
|
// files. Other entities must stay.
|
||||||
.replace(/”/g, '”')
|
[ '“', '“' ],
|
||||||
.replace(/‘/g, '‘')
|
[ '”', '”' ],
|
||||||
.replace(/’/g, '’');
|
[ '‘', '‘' ],
|
||||||
}
|
[ '’', '’' ],
|
||||||
return document.createTextNode(text);
|
[ '<', '<' ],
|
||||||
};
|
[ '>', '>' ],
|
||||||
|
]);
|
||||||
|
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) {
|
var safeTextToDOM = function(text, parent) {
|
||||||
if ( text === '' ) { return; }
|
if ( text === '' ) { return; }
|
||||||
|
|
Loading…
Reference in New Issue