sanitizing unsafe URL value javascript:;
See original GitHub issueAngular 2 final release.
I have my link as following with refers to the href=“javascript:;” my link
and i am getting following warning
WARNING: sanitizing unsafe URL value javascript:; (see http://g.co/ng/security#xss)
I need my link to be javascript:; because if i make it ‘#’ or ‘’ it refreshes the page.
i am generating elements dynamically. they can have direct links or drop downs. if they link i use url to populate in href. if they drop down i make href as void(0); so clicking on it should not refresh the page.
I have read couple of posts where people report this issue to angular folks and they will fix it… any help is appreciated.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
WARNING: sanitizing unsafe style value url - Stack Overflow
This is the warning I see in my console (I have changed my img url to /img/path/is/correct. png : WARNING: sanitizing unsafe style...
Read more >2 ways to fix WARNING: sanitizing unsafe URL value in Angular
This HTML binding throws WARNING: sanitizing unsafe URL value because of href="javascript:alert('safe html').
Read more >DomSanitizer - Angular
DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing values to be safe to use in the different DOM contexts.
Read more >unsafe value used in a resource url context
Overview. Sanitizes an html string by stripping all potentially dangerous tokens. The input is sanitized by parsing the HTML into tokens. All safe...
Read more >sanitizing unsafe URL value data:text/html;base64,-angular.js
Coding example for the question WARNING: sanitizing unsafe URL value data:text/html;base64,-angular.js.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t think you want to trick sanitization here. If you are using a link that has a click event and it shouldn’t trigger navigation just prevent default action on the event, ex.:
<a (click)="$event.preventDefault(); doSth()">
or even shorter<a (click)="!!doSth()">
A link without a
href
tag is not considered clickable.Firefox will be happy to not put the right cursor for <a> tags missing a href.