Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8979135

Browse files
author
Eugene Bannykh
committed
MAGEDOC-2656: fix XSS in search on devdocs
1 parent 630d780 commit 8979135

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

_layouts/search.md renamed to _layouts/search.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</div>
2323

2424
<link rel="stylesheet" href="https://cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.css">
25-
<script src="https://cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.js"></script>
25+
<script src="https://cdn.jsdelivr.net/npm/instantsearch.js@1/dist/instantsearch.min.js"></script>
2626

2727
<script>
2828

@@ -33,6 +33,11 @@
3333
urlSync: true
3434
});
3535

36+
function escapeHtml(str) {
37+
var div = document.createElement('div');
38+
div.appendChild(document.createTextNode(str));
39+
return div.innerHTML;
40+
}
3641

3742
function app(opts) {
3843
var switcher = document.getElementsByClassName('version-switcher')[0];
@@ -91,9 +96,8 @@
9196

9297
return '<div class="hit"><h2 class="hit-name">'+ link + '</h2><div class="hit-url">'+ document.location.origin + url +'</div><div class="hit-content">'+ item._highlightResult.text.value + '</div></div>';
9398
},
94-
empty: function ( query ) {
95-
return '<div id="no-results-message"><p>No results for the search <em>"' + query.query +'"</em>.</p></div>';
96-
},
99+
empty: '<div id="no-results-message"><p>No results found.</p></div>',
100+
97101
},
98102
})
99103
);
@@ -105,6 +109,7 @@
105109
);
106110

107111

112+
108113
search.addWidget(
109114
instantsearch.widgets.refinementList({
110115
container: '#tags',

0 commit comments

Comments
 (0)