Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nz-select组件multiple模式安全问题 #6209

Closed
facelesswu opened this issue Dec 16, 2020 · 2 comments · Fixed by #6222
Closed

nz-select组件multiple模式安全问题 #6209

facelesswu opened this issue Dec 16, 2020 · 2 comments · Fixed by #6222

Comments

@facelesswu
Copy link

Reproduction link

https://stackblitz.com/edit/angular-q2g3qd?file=src%2Fapp%2Fapp.component.ts

Steps to reproduce

在select输入框输入<img src='x' onerror='alert(1)'>,此时浏览器会出现alert弹窗

What is expected?

不应该弹出浏览器对话框

What is actually happening?

弹出浏览器对话框

Environment Info
ng-zorro-antd 10.1.1
Browser chrome 87.0.4280.88

经查阅源码发现,在 components/select/select-search.component.ts 文件 syncMirrorWidth 方法中使用了不安全的 innerHTML 赋值,应改为使用 textContent 或者 renderer2.createText() 方法

@zhengsansan
Copy link

到底是咋修复的?需要升级到11.0.0版本才行吗?

@tyzh
Copy link

tyzh commented Nov 4, 2021

mirrorDOM.innerHTML = this.renderer.createText(${inputDOM.value}&nbsp;);

the result of createText is an object, so this code will cause the innerHTML of mirrorDOM is '[object Text]'

createText方法的返回结果是一个对象,这样赋值会导致mirrorDOM元素的innerHTML为 [object Text]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants