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.

Allow customizing SAFE_URL_PATTERN in url_sanitizer.ts

See original GitHub issue

I’m submitting a … (check one with “x”)

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior It is not possible to customize which URLs are considered safe.

Expected behavior A user could customize the REGEX used to match safe urls.

Minimal reproduction of the problem with instructions N/A

What is the motivation / use case for changing the behavior? When you are using ionic 2, Android will usually return URLs that begin with content://. Then you have to explicitly call bypassSecurityTrustUrl to be able to show them. In Angular 1 you could customize this by injecting $compileProvider and calling: $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|blob|content):|data:image\//);. But there’s no convenience alternative for angular 2.

Please tell us about your environment: N/A

  • Angular version: 2.0.X 2.2.0-rc.0

  • Browser: all

  • Language: all

  • Node (for AoT issues): node --version = 7.1.0

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mprobstcommented, Nov 16, 2016

Thanks for the explanation! We’ll need to assess whether we can generally trust content://. @rjamet is out for a week, but we’ll get back to it.

For the time being I’d recommend writing a pipe so you can write:

<img src="{{ something | trustContentUrl }}">

Make sure to validate it’s a content:// URL in the expected format, and only trust as URL, but not as a resource URL.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 10, 2019

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

WARNING: sanitizing unsafe style value url - Stack Overflow
You have to wrap the entire url statement in the bypassSecurityTrustStyle : <div class="header" *ngIf="image" ...
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 >
Angular 2 - Dynamic URLs Sanitizer - Talking HighTech
Sanitization is the inspection of an untrusted value, turning it into a value that is safe to insert into the DOM. In many...
Read more >
Customizing the URL format for files in CloudFront
Describes the format of URLs for working with CloudFront objects when you want to reference objects in your website or application.
Read more >
sanitize-html - npm
Allowing particular urls as a src to an iframe tag by filtering hostnames is also supported. HTML comments are not preserved. Additionally, ...
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