4
votes
Cycode scan recommends HTML sanitization for iframe.src assignment, but I'm only using a URL—what is the proper mitigation?
Instead of regex sanitization, construct the URL safely and encode parameters properly
const authToken =
sessionStorage.getItem('auth_token') ??
this.sessionStorage.retrieve('authenticationtoken') ...
2
votes
Cycode scan recommends HTML sanitization for iframe.src assignment, but I'm only using a URL—what is the proper mitigation?
Seikh Imran's answer is probably more idiomatic for contemporary JavaScript, but this approach is equally as secure, but a little older: use the encodeURIComponent function.
const auth_token = ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
iframe × 32563javascript × 15950
html × 12186
jquery × 7329
css × 4192
php × 2196
youtube × 1134
selenium-webdriver × 1115
facebook × 825
asp.net × 823
google-chrome × 805
cross-domain × 696
internet-explorer × 652
reactjs × 647
ajax × 603
wordpress × 585
python × 572
embed × 566
c# × 508
angularjs × 506
ios × 505
angular × 488
firefox × 466
dom × 451
pdf × 447