am 3534dadd: docs: fix XSS vulnerability in search
Merge commit '3534daddeefefbd42ea0a3819348327e5d85315c' into eclair * commit '3534daddeefefbd42ea0a3819348327e5d85315c': docs: fix XSS vulnerability in search
This commit is contained in:
@@ -70,8 +70,8 @@ page.title=Search Results
|
|||||||
searchControl.setSearchStartingCallback(this, function(control, searcher, query) {
|
searchControl.setSearchStartingCallback(this, function(control, searcher, query) {
|
||||||
// save the tab index from the hash
|
// save the tab index from the hash
|
||||||
tabIndex = location.hash.split("&t=")[1];
|
tabIndex = location.hash.split("&t=")[1];
|
||||||
|
|
||||||
$("#searchTitle").html("search results for <em>" + query + "</em>");
|
$("#searchTitle").html("search results for <em>" + escapeHTML(query) + "</em>");
|
||||||
$.history.add('q=' + query + '&t=' + tabIndex);
|
$.history.add('q=' + query + '&t=' + tabIndex);
|
||||||
openTab();
|
openTab();
|
||||||
});
|
});
|
||||||
@@ -96,7 +96,8 @@ page.title=Search Results
|
|||||||
$(window).history(function(e, hash) {
|
$(window).history(function(e, hash) {
|
||||||
var query = decodeURI(getQuery(hash));
|
var query = decodeURI(getQuery(hash));
|
||||||
searchControl.execute(query);
|
searchControl.execute(query);
|
||||||
$("#searchTitle").html("search results for <em>" + query + "</em>");
|
|
||||||
|
$("#searchTitle").html("search results for <em>" + escapeHTML(query) + "</em>");
|
||||||
});
|
});
|
||||||
|
|
||||||
// forcefully regain key-up event control (previously jacked by search api)
|
// forcefully regain key-up event control (previously jacked by search api)
|
||||||
@@ -131,6 +132,13 @@ page.title=Search Results
|
|||||||
return queryParts[1];
|
return queryParts[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* returns the given string with all HTML brackets converted to entities
|
||||||
|
TODO: move this to the site's JS library */
|
||||||
|
function escapeHTML(string) {
|
||||||
|
return string.replace(/</g,"<")
|
||||||
|
.replace(/>/g,">");
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="mainBodyFixed" style="width:auto; margin:20px">
|
<div id="mainBodyFixed" style="width:auto; margin:20px">
|
||||||
|
|||||||
Reference in New Issue
Block a user