Closed Bug 417836 Opened 17 years ago Closed 16 years ago

Canvas's .getImageData throws when accessing <img src="data:...">

Categories

(Core :: Graphics: Canvas2D, defect, P2)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: Dolske, Assigned: vlad)

References

Details

Attachments

(2 files, 3 obsolete files)

Attached file Testcase (deleted) —
I was trying to make a self-contained testcase for another bug, and ran into this. The (attached) HTML testcase loads from images via data: URIs, and uses drawImage() to paint them on a <canvas>. When calling .getImageData(), I get: Crap, run_test failed: [Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)" location: "file:///Users/dolske/Desktop/testjpeg.html Line: 36"] I thought this might be a result of bug 230606, but it happens when the HTML is served via http:// too.
Priority: -- → P2
Flags: blocking1.9.1?
bz suggests that this is all imglib's fault, and that we should just work around it by special-casing data URIs in canvas. I buy that suggestion.
Assignee: nobody → vladimir
Flags: wanted1.9.1+
Flags: blocking1.9.1?
Flags: blocking1.9.1-
Attached patch maybe something like this? (obsolete) (deleted) — Splinter Review
Boris, would something like this work? This basically changes the security check to accept a NULL principal as "everything's ok", but only set a NULL principal in the data URI case, otherwise require a principal.
Attachment #329891 - Flags: review?(bzbarsky)
Comment on attachment 329891 [details] [diff] [review] maybe something like this? >+++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp >+ // Special-case data URIs >+ nsCOMPtr<nsIURI> uri; >+ rv = aPrincipal->GetURI(getter_AddRefs(uri)); When would we get a principal with a data: URI as the URI? >+ PRBool ok = PR_FALSE; >+ >+ // Data URIs are always OK >+ if (!ok && scheme.LowerCaseEqualsLiteral("data")) >+ ok = PR_TRUE; >+ >+ if (ok) { Couldn't all that be: if (scheme.LowerCaseEqualsLiteral("data")) { ?
(In reply to comment #3) > (From update of attachment 329891 [details] [diff] [review]) > >+++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp > >+ // Special-case data URIs > >+ nsCOMPtr<nsIURI> uri; > >+ rv = aPrincipal->GetURI(getter_AddRefs(uri)); > > When would we get a principal with a data: URI as the URI? Oh whoops, forgot to remove that part of the patch. That was the earlier failed attempt. > > >+ PRBool ok = PR_FALSE; > >+ > >+ // Data URIs are always OK > >+ if (!ok && scheme.LowerCaseEqualsLiteral("data")) > >+ ok = PR_TRUE; > >+ > >+ if (ok) { > > Couldn't all that be: > > if (scheme.LowerCaseEqualsLiteral("data")) { > > ? It could, and I should probably change it -- I was thinking we might want to special-case other types as well, but that can just be ||..
Attached patch updated (obsolete) (deleted) — Splinter Review
Got rid of the wrong principal bit and the 'ok' bit..
Attachment #329891 - Attachment is obsolete: true
Attachment #329927 - Flags: review?(bzbarsky)
Attachment #329891 - Flags: review?(bzbarsky)
Comment on attachment 329927 [details] [diff] [review] updated looks ok. File a followup to remove this when we fix imagelib?
Attachment #329927 - Flags: review?(bzbarsky) → review+
Why not use SchemeIs?
Attached patch use SchemeIs (obsolete) (deleted) — Splinter Review
Hrm. Yes. SchemeIs it is..
Attachment #329927 - Attachment is obsolete: true
Attachment #330480 - Flags: review?(gavin.sharp)
Comment on attachment 330480 [details] [diff] [review] use SchemeIs Looks like you attached the wrong patch.
Attachment #330480 - Attachment is obsolete: true
Attachment #330480 - Flags: review?(gavin.sharp)
Attached patch updated (deleted) — Splinter Review
Weird. Dunno how that happened, sorry. Correct one this time.
Attachment #330535 - Flags: review?(gavin.sharp)
Blocks: 444641
Checked in (with removed assertion)
I hate the new bugzilla
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: