diff --git a/source/javascripts/app/search.js b/source/javascripts/app/search.js index cb81989..a7ed873 100644 --- a/source/javascripts/app/search.js +++ b/source/javascripts/app/search.js @@ -53,7 +53,7 @@ }); highlight.call(this); } else { - searchResults.html('
  • No Results Found for "' + this.value + '"
  • '); + searchResults.html('
  • No Results Found for "' + this.value.escapeHTML() + '"
  • '); } } else { unhighlight(); @@ -69,4 +69,19 @@ content.unhighlight(highlightOpts); } + var __entityMap = { + "&": "&", + "<": "<", + ">": ">", + '"': '"', + "'": ''', + "/": '/' + }; + + String.prototype.escapeHTML = function() { + return String(this).replace(/[&<>"'\/]/g, function (s) { + return __entityMap[s]; + }); + } + })(window);