mirror of
https://github.com/danbulant/api_docs
synced 2026-06-09 17:41:44 +00:00
fixed XSS vuln in searchbox
This commit is contained in:
parent
9c7ea33305
commit
b40b3b47ed
1 changed files with 16 additions and 1 deletions
|
|
@ -53,7 +53,7 @@
|
||||||
});
|
});
|
||||||
highlight.call(this);
|
highlight.call(this);
|
||||||
} else {
|
} else {
|
||||||
searchResults.html('<li>No Results Found for "' + this.value + '"</li>');
|
searchResults.html('<li>No Results Found for "' + this.value.escapeHTML() + '"</li>');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unhighlight();
|
unhighlight();
|
||||||
|
|
@ -69,4 +69,19 @@
|
||||||
content.unhighlight(highlightOpts);
|
content.unhighlight(highlightOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var __entityMap = {
|
||||||
|
"&": "&",
|
||||||
|
"<": "<",
|
||||||
|
">": ">",
|
||||||
|
'"': '"',
|
||||||
|
"'": ''',
|
||||||
|
"/": '/'
|
||||||
|
};
|
||||||
|
|
||||||
|
String.prototype.escapeHTML = function() {
|
||||||
|
return String(this).replace(/[&<>"'\/]/g, function (s) {
|
||||||
|
return __entityMap[s];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
})(window);
|
})(window);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue