Skip to content

Commit c72be5b

Browse files
committed
Fix AJAX example handling of query parameters
The example was injecting the query parameters as HTML, which allowed for arbitrary javascript to be ran (for ex. through an `onerror` attribute on an image). As the value only needs displaying, the query parameter is now displayed via text content.
1 parent 96bf629 commit c72be5b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

examples/ajax-source.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ <h1>Accessible Autocomplete AJAX source example</h1>
292292
var submittedEl = document.querySelector('.submitted')
293293
submittedEl.classList.remove('submitted--hidden')
294294
var params = new URLSearchParams(document.location.search.split('?')[1])
295-
document.querySelector('.submitted__last-location').innerHTML = params.get('last-location')
296-
document.querySelector('.submitted__passport-location').innerHTML = params.get('passport-location')
295+
document.querySelector('.submitted__last-location').textContent = params.get('last-location')
297296
}
298297
</script>
299298
</body>

0 commit comments

Comments
 (0)