mirror of
https://bitbucket.org/grumdrig/pq-web.git
synced 2026-09-29 00:34:00 -06:00
Escape HTML
This commit is contained in:
@@ -15,6 +15,11 @@ function tabulate(list) {
|
||||
}
|
||||
|
||||
|
||||
String.prototype.escapeHtml = function () {
|
||||
return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
||||
}
|
||||
|
||||
|
||||
function template(tmpl, data) {
|
||||
var brag = tmpl.replace(/\$([_A-Za-z.]+)/g, function (str, p1) {
|
||||
var dict = data;
|
||||
@@ -24,6 +29,8 @@ function template(tmpl, data) {
|
||||
dict = tabulate(dict);
|
||||
} else {
|
||||
dict = dict[v.replace("_"," ")];
|
||||
if (typeof dict == typeof "")
|
||||
dict = dict.escapeHtml();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user