fixed XSS vuln in searchbox

This commit is contained in:
Kevin Adams 2014-10-08 16:38:46 -07:00
parent 9c7ea33305
commit b40b3b47ed

View file

@ -53,7 +53,7 @@
});
highlight.call(this);
} else {
searchResults.html('<li>No Results Found for "' + this.value + '"</li>');
searchResults.html('<li>No Results Found for "' + this.value.escapeHTML() + '"</li>');
}
} else {
unhighlight();
@ -69,4 +69,19 @@
content.unhighlight(highlightOpts);
}
var __entityMap = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': '&quot;',
"'": '&#39;',
"/": '&#x2F;'
};
String.prototype.escapeHTML = function() {
return String(this).replace(/[&<>"'\/]/g, function (s) {
return __entityMap[s];
});
}
})(window);