Skip to content

Commit 5ed0293

Browse files
committed
Merge pull request #10 from AnshuHanda/escape-urls
Escape urls
2 parents e2850aa + 33c46ac commit 5ed0293

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

unbxdSearch.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,8 @@ var unbxdSearchInit = function(jQuery, Handlebars){
981981
var nonhistoryPath = "";
982982

983983
if(this.options.type == "search" && this.params['query'] != undefined){
984-
url += '&q=' + encodeURIComponent(this.params.query);
984+
var escapedQuery = this.params.query.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g, "\\$&");
985+
url += '&q=' + encodeURIComponent(escapedQuery);
985986
}else if(this.options.type == "browse" && this.params['categoryId'] != undefined){
986987
url += '&category-id=' + encodeURIComponent(this.params.categoryId);
987988
}
@@ -1339,7 +1340,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
13391340
this.totalPages = Math.ceil(obj.response.numberOfProducts/this.getPageSize());
13401341

13411342
jQuery(this.options.searchQueryDisplay).html(this.compiledSearchQueryTemp({
1342-
query : obj.searchMetaData.queryParams.q
1343+
query : obj.searchMetaData.queryParams.q.replace(/\\/g,"")
13431344
,numberOfProducts : obj.response.numberOfProducts
13441345
,start: this.productStartIdx
13451346
,end: this.productEndIdx

0 commit comments

Comments
 (0)