Skip to content

Commit

Permalink
prevent potential XSS from searchbar results (#342)
Browse files Browse the repository at this point in the history
* prevent potential XSS from searchbar results

* use built in handlebars expression escaping

* use handlebars encodeURIComponent
  • Loading branch information
diegocepedaw authored Feb 5, 2021
1 parent 605d10e commit 843bc10
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/oncall/ui/static/js/oncall.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,11 +579,11 @@ var oncall = {
},
footer: function(resp){
if (teamsCt > typeaheadLimit) {
return '<div class="tt-see-all"><a href="/query/' + resp.query + '/teams" data-navigo> See all ' + teamsCt + ' results for teams »</a></div>';
return '<div class="tt-see-all"><a href="/query/' + Handlebars.escapeExpression(encodeURIComponent(resp.query)) + '/teams" data-navigo> See all ' + teamsCt + ' results for teams »</a></div>';
}
},
empty: function(resp){
return '<h4> No results found for "' + resp.query + '" </h4>';
return '<h4> No results found for "' + Handlebars.escapeExpression(resp.query) + '" </h4>';
}
}
},
Expand All @@ -604,7 +604,7 @@ var oncall = {
},
footer: function(resp){
if (servicesCt > typeaheadLimit) {
return '<div class="tt-see-all"><a href="/query/' + resp.query + '/services" data-navigo> See all ' + servicesCt + ' results for services »</a></div>';
return '<div class="tt-see-all"><a href="/query/' + Handlebars.escapeExpression(encodeURIComponent(resp.query)) + '/services" data-navigo> See all ' + servicesCt + ' results for services »</a></div>';
}
}
}
Expand All @@ -626,7 +626,7 @@ var oncall = {
},
footer: function(resp){
if (usersCt > typeaheadLimit) {
return '<div class="tt-see-all"><a href="/query/' + resp.query + '/users" data-navigo> See all ' + usersCt + ' results for users »</a></div>';
return '<div class="tt-see-all"><a href="/query/' + Handlebars.escapeExpression(encodeURIComponent(resp.query)) + '/users" data-navigo> See all ' + usersCt + ' results for users »</a></div>';
}
}
}
Expand Down

0 comments on commit 843bc10

Please sign in to comment.