Skip to content

Commit

Permalink
fixed XSS vuln in searchbox
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-buttercoin committed Oct 8, 2014
1 parent 9c7ea33 commit b40b3b4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion source/javascripts/app/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);

0 comments on commit b40b3b4

Please sign in to comment.