Просмотр исходного кода

Fixed double escaping

calling escapeHtml(escapeHtml(escapeHtml(escapeHtml('&')))) results in
&
pull/531/head
Silviu Marian 10 лет назад
Родитель
Сommit
e47231ea26
1 измененных файлов: 4 добавлений и 6 удалений
  1. +4
    -6
      mustache.js

+ 4
- 6
mustache.js Просмотреть файл

@@ -58,7 +58,6 @@
}

var entityMap = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
@@ -67,11 +66,10 @@
'`': '&#x60;',
'=': '&#x3D;'
};

function escapeHtml (string) {
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
return entityMap[s];
});
function escapeHtml(string) {
return String(string)
.replace(/[<>"'\/]/g, function (s) { return entityMap[s]; })
.replace(/&(?![A-Za-z0-9#][A-Za-z0-9]+;)+/g, '&amp;');
}

var whiteRe = /\s*/;


Загрузка…
Отмена
Сохранить