Title: Add an ability to change SAFE_URL_PATTERN for app/service/component · Issue #49075 · angular/angular · GitHub
Open Graph Title: Add an ability to change SAFE_URL_PATTERN for app/service/component · Issue #49075 · angular/angular
X Title: Add an ability to change SAFE_URL_PATTERN for app/service/component · Issue #49075 · angular/angular
Description: Which @angular/* package(s) are relevant/related to the feature request? core Description Here we have limited safe protocols. https://github.com/angular/angular/blob/main/packages/core/src/sanitization/url_sanitizer.ts#L37 For example, ...
Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? core Description Here we have limited safe protocols. https://github.com/angular/angular/blob/main/packages/core/src/sanitiz...
X Description: Which @angular/* package(s) are relevant/related to the feature request? core Description Here we have limited safe protocols. https://github.com/angular/angular/blob/main/packages/core/src/sanitiz...
Opengraph URL: https://github.com/angular/angular/issues/49075
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add an ability to change SAFE_URL_PATTERN for app/service/component","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\n\ncore\n\n### Description\n\nHere we have limited safe protocols.\r\nhttps://github.com/angular/angular/blob/main/packages/core/src/sanitization/url_sanitizer.ts#L37\r\n\r\nFor example, my backend returned HTML-layout (some article, for example) with links for Telegram or Steam client, them have own protocol - `tg://` and `steam://`. And I want to make it safe, but without calling the `bypassSecurityTrustHtml` that force doing all protocols are safe.\n\n### Proposed solution\n\nIdeally for me it should be DI config, where I can set my safeUrlPatterns.\r\nFor example:\r\n```ts\r\n@Component({\r\n selector: 'app-my-article',\r\n standalone: true,\r\n imports: [\r\n SanitizerModule.forRoot({\r\n // Flexible but not user friendly options\r\n safeUrlPatterns: /^(?:(?:ts|steam):|[^&:/?#]*(?:[/?#]|$))/gi,\r\n // Or just define protocols\r\n safeUrlProtocols: ['tg', 'steam'],\r\n }),\r\n ],\r\n})\r\n```\n\n### Alternatives considered\n\nFor now I should call the `bypassSecurityTrustHtml` method that make more than I want, and it's not safe for this task.\r\n\r\nRelative issues:\r\nhttps://github.com/angular/angular/issues/12840#issuecomment-261026830\r\nHere described how to work just with the src attribute on the element.\r\nBut my question is about full html article that we getting from backend. It can contain any layout and tags by WYSISYG, including links.\r\n\r\nhttps://github.com/angular/angular/issues/31462\r\nHere author just adding some protocols. It's good for standarts supporting, but not provide flexible controls on the sanitizer rules.","author":{"url":"https://github.com/Dok11","@type":"Person","name":"Dok11"},"datePublished":"2023-02-15T14:29:55Z","url":"https://github.com/angular/angular/issues/49075"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d040391f-ec85-eb06-f064-221005169caa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B2EC:2DBB21:CEE791:114D5F1:6B00FF89 |
| html-safe-nonce | 50bc9c6e087f6cea55f65d47589b21ab2388b68ccf287c830cc6a35066c4e769 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkVDOjJEQkIyMTpDRUU3OTE6MTE0RDVGMTo2QjAwRkY4OSIsInZpc2l0b3JfaWQiOiI1NTQwOTU2MTkxMDQxMDYwNzQ2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1abde626bf600a7abab91a8624bc18f1ac3ca91ccb32a35ad58502c83305118a |
| hovercard-subject-tag | issue:1585960378 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/49075/issue_layout |
| twitter:image | https://opengraph.githubassets.com/74d4c45b898583ac6b72bb557ca425d80ab703faf841a40cd75a3b3a4d2c5408/angular/angular/issues/49075 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/74d4c45b898583ac6b72bb557ca425d80ab703faf841a40cd75a3b3a4d2c5408/angular/angular/issues/49075 |
| og:image:alt | Which @angular/* package(s) are relevant/related to the feature request? core Description Here we have limited safe protocols. https://github.com/angular/angular/blob/main/packages/core/src/sanitiz... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Dok11 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width