fix: update escape_html to escape quotes

previous jquery hack didn't escape double quotes.
This commit is contained in:
Ankush Menat 2021-03-17 14:53:13 +05:30
parent 9b2946d234
commit bf6d336e95
No known key found for this signature in database
GPG key ID: 8EA82E09BBD13AAF

View file

@ -220,8 +220,23 @@ Object.assign(frappe.utils, {
});
return out.join(newline);
},
escape_html: function(txt) {
return $("<div></div>").text(txt || "").html();
let escape_html_mapping = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
'/': '&#x2F;',
'`': '&#x60;',
'=': '&#x3D;'
};
return String(txt).replace(/[&<>"'`=/]/g, function(char) {
return escape_html_mapping[char];
});
},
html2text: function(html) {