question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for AngularJS aHrefSanitizationTrustedUrlList feature

See original GitHub issue

I can’t find a way to port the feature we have in our AngularJS to our Angular app:

https://docs.angularjs.org/api/ng/provider/$compileProvider#aHrefSanitizationTrustedUrlList

If i google around they all say use the https://angular.io/api/platform-browser/DomSanitizer but thats not the same, As far as i can see that only tells us that we want to trust more (possible unsafe stuff) But we want the other way around we want to be more stricter if sanitize happens… If we have a following html template:

<span>hello</span><a href="https://evil.com">My Nice Link</a><span>please click</span>

And i place that on an Angular component that displays that html Then i want that angular makes it:

<span>hello</span><a href="unsafe:https://evil.com">My Nice Link</a><span>please click</span>

or something like that, in AngularJS it just fully removes the href attribute if i i set an allowed/trusted url list. (which doesnt include evil.com)

But no matter where i look that just isn’t possible right now? it seems only if i do:

<span>hello</span><a href="javascript:xxxx">My Nice Link</a><span>please click</span>

angular makes it

<span>hello</span><a href=""unsafe:javascript:xxxx">My Nice Link</a><span>please click</span>

I would love to have a hook that after the current Angular implementation says i don’t do anything with that url that i can still say no this is also unsafe.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
petebacondarwincommented, May 12, 2021

While one ought to be able to override the DomSanitizer with your own implementation, I don’t quite see how we can do this with Ivy code, since it doesn’t rely upon the DI to get the sanitizer implementation. See https://stackblitz.com/edit/angular-ivy-n9a6jc?file=src%2Fapp%2Fapp.module.ts

0reactions
angular-automatic-lock-bot[bot]commented, Apr 28, 2022

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

$compileProvider - AngularJS: API
Returns. ng.$compileProvider. the compile provider itself, for chaining of function calls. aHrefSanitizationTrustedUrlList ...
Read more >
Miscellaneous: Version Support Status - AngularJS: API
Visit angular.io for the actively supported Angular. What does end of support mean? The code will remain accessible on GitHub, npm, Bower, and...
Read more >
AngularJS: Developer Guide: Migrating from Previous Versions
Implementing long awaited features, such as support for inputs of type range and the ability to bind to any type of values using...
Read more >
$sce - AngularJS: API
$sce is a service that provides Strict Contextual Escaping services to AngularJS. Strict Contextual Escaping. Strict Contextual Escaping (SCE) is a mode in ......
Read more >
AngularJS: API: API Reference
Visit angular.io for the actively supported Angular. ... Use ngAnimate to enable animation features within your application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found