Browse Source

Fixes #1033 issue with XSS in popup

pull/1063/head
jlukic 10 years ago
parent
commit
259fd6f0db
1 changed files with 40 additions and 8 deletions
  1. 48
      src/definitions/modules/popup.js

48
src/definitions/modules/popup.js

@ -901,17 +901,49 @@ $.fn.popup.settings = {
popup : '.ui.popup'
},
template: function(text) {
var html = '';
if(typeof text !== undefined) {
if(typeof text.title !== undefined && text.title) {
html += '<div class="header">' + text.title + '</div class="header">';
escape: function() {
},
templates: {
escape: function(string) {
var
badChars = /[&<>"'`]/g,
shouldEscape = /[&<>"'`]/,
escape = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#x27;",
"`": "&#x60;"
},
escapedChar = function(chr) {
return escape[chr];
}
;
if(shouldEscape.test(string)) {
return string.replace(badChars, escapedChar);
}
if(typeof text.content !== undefined && text.content) {
html += '<div class="content">' + text.content + '</div>';
return string;
},
popup: function(text) {
var
html = '',
escape = $.fn.popup.settings.templates.escape
;
if(typeof text !== undefined) {
if(typeof text.title !== undefined && text.title) {
text.title = escape(text.title);
html += '<div class="header">' + text.title + '</div class="header">';
}
if(typeof text.content !== undefined && text.content) {
text.content = escape(text.content);
html += '<div class="content">' + text.content + '</div>';
}
}
return html;
}
return html;
}
};

Loading…
Cancel
Save