当图片跨域todataurl被污染的解决方案
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
```
getBase64FromImageUrl(URL) {
let img = new Image()
img.setAttribute('crossOrigin', 'anonymous')
img.src = URL
let that = this
img.onload = function() {
let canvas = document.createElement('canvas')
canvas.width = this.width
canvas.height = this.height
let ctx = canvas.getContext('2d')
ctx.drawImage(this, 0, 0)
let dataURL = canvas.toDataURL('image/png')
that.dataURL = dataURL
alert(dataURL.replace(/^data:image\/(png|jpg);base64,/, ''))
}
}
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the getBase64FromImageUrl(URL) snippet and inspect how the Image, canvas, and toDataURL calls interact. Determine the browser-side conditions needed for cross-origin images, then verify that the function produces an untainted data URL for a permitted remote image without failing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100