ionic-team / ionic-team/ionic-framework
bug: ion-img src does not work when bypassing angular sanitizer for a url
- 主要语言
- TypeScript
- 星标
- 52.7k
- 派生
- 13.3k
- 平均合并
- 1 天 14 小时
- 30 天内合并 PR
- 50
描述
# Bug Report
**Ionic version:**
[x] **4.x**
**Current behavior:**
ionImg (used together with ionVirtualScroll) does not work with src values that have been sanitized using `safeUrl = domSanitizer.bypassSecurityTrustUrl(url);`. It throws and error like
`"capacitor://localhost/SafeValue must use [property]=binding: capacitor://localhost/_capacitor_file_/Users/user/Library/.../Library/Caches/img/C409D956-DE09-406D-A7EF-3207DF705B64-L0-001~100x100.JPG (see http://g.co/ng/security#xss)`
```html
```
This probably happens because `ionImg` outputs IMG.src without using `[src]=binding`.
```
);
```
see: https://github.com/ionic-team/ionic/blob/master/core/src/components/img/img.tsx
**Expected behavior:**
It should display the sanitized url, the same as the `HTMImageElement`.
**Steps to reproduce:**
see above
**Related code:**
https://stackblitz.com/edit/ionic-v4-angular-tabs-6um4j8
**Other information:**
**Ionic info:**
```
Ionic:
Ionic CLI : 5.2.3 (/Users/michael/.nvm/versions/node/v8.9.4/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.4.2
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
Capacitor:
Capacitor CLI : 1.0.0
@capacitor/core : 1.0.0
Cordova:
Cordova CLI : 8.0.0
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (1 plugins total)
Utility:
cordova-res : not installed
native-run : 0.2.8
System:
ios-deploy : 2.0.0
NodeJS : v8.9.4 (/Users/michael/.nvm/versions/node/v8.9.4/bin/node)
npm : 6.9.0
OS : macOS Mojave
Xcode : Xcode 10.3 Build version 10G8
```
贡献指南
调研方向
从 core/src/components/img/img.tsx 开始,使用链接的 StackBlitz 示例重现该问题,比较 ion-img 与原生 img 绑定对经过清理的 URL 的处理。完成标准是 ion-img 能够显示经过清理的 URL 且不出现 SafeValue 错误,同时保留现有的 virtual-scroll 行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- angular, typescript
- 领域
- frontend, mobile-dev
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 38/100