mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 09:43:06 +00:00
fix potential XSS in search (#492)
mostly it looks like a self-XSS but still good to fix
This commit is contained in:
parent
d7a4481ff2
commit
d198cbe65f
1 changed files with 12 additions and 9 deletions
|
@ -75,15 +75,18 @@ $( document ).ready(function() {
|
||||||
"(?:\\s?(?:[\\w]+)\\s?){0,"+numContextWords+"}" +
|
"(?:\\s?(?:[\\w]+)\\s?){0,"+numContextWords+"}" +
|
||||||
term+"(?:\\s?(?:[\\w]+)\\s?){0,"+numContextWords+"}");
|
term+"(?:\\s?(?:[\\w]+)\\s?){0,"+numContextWords+"}");
|
||||||
item.context = text;
|
item.context = text;
|
||||||
return '<div class="autocomplete-suggestion" ' +
|
var divcontext = document.createElement("div");
|
||||||
'data-term="' + term + '" ' +
|
divcontext.className = "context";
|
||||||
'data-title="' + item.title + '" ' +
|
divcontext.innerText = (item.context || '');
|
||||||
'data-uri="'+ item.uri + '" ' +
|
var divsuggestion = document.createElement("div");
|
||||||
'data-context="' + item.context + '">' +
|
divsuggestion.className = "autocomplete-suggestion";
|
||||||
'» ' + item.title +
|
divsuggestion.setAttribute("data-term", term);
|
||||||
'<div class="context">' +
|
divsuggestion.setAttribute("data-title", item.title);
|
||||||
(item.context || '') +'</div>' +
|
divsuggestion.setAttribute("data-uri", item.uri);
|
||||||
'</div>';
|
divsuggestion.setAttribute("data-context", item.context);
|
||||||
|
divsuggestion.innerText = '» ' + item.title;
|
||||||
|
divsuggestion.appendChild(divcontext);
|
||||||
|
return divsuggestion.outerHTML;
|
||||||
},
|
},
|
||||||
/* onSelect callback fires when a search suggestion is chosen */
|
/* onSelect callback fires when a search suggestion is chosen */
|
||||||
onSelect: function(e, term, item) {
|
onSelect: function(e, term, item) {
|
||||||
|
|
Loading…
Reference in a new issue