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)
Core
Graphics: Canvas2D
Tracking
()
RESOLVED
FIXED
People
(Reporter: Dolske, Assigned: vlad)
References
Details
Attachments
(2 files, 3 obsolete files)
(deleted),
text/html
|
Details | |
(deleted),
patch
|
Gavin
:
review+
|
Details | Diff | Splinter Review |
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.
Updated•17 years ago
|
Priority: -- → P2
Reporter | ||
Updated•16 years ago
|
Flags: blocking1.9.1?
Assignee | ||
Comment 1•16 years ago
|
||
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-
Assignee | ||
Comment 2•16 years ago
|
||
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 3•16 years ago
|
||
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")) {
?
Assignee | ||
Comment 4•16 years ago
|
||
(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 ||..
Assignee | ||
Comment 5•16 years ago
|
||
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 6•16 years ago
|
||
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+
Comment 7•16 years ago
|
||
Why not use SchemeIs?
Assignee | ||
Comment 8•16 years ago
|
||
Hrm. Yes. SchemeIs it is..
Attachment #329927 -
Attachment is obsolete: true
Attachment #330480 -
Flags: review?(gavin.sharp)
Comment 9•16 years ago
|
||
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)
Assignee | ||
Comment 10•16 years ago
|
||
Weird. Dunno how that happened, sorry. Correct one this time.
Attachment #330535 -
Flags: review?(gavin.sharp)
Comment 11•16 years ago
|
||
Comment on attachment 330535 [details] [diff] [review]
updated
Also need to remove the assertion at:
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/content/canvas/src/nsCanvasRenderingContext2D.cpp&mark=241#229
Attachment #330535 -
Flags: review?(gavin.sharp) → review+
Assignee | ||
Comment 12•16 years ago
|
||
Checked in (with removed assertion)
Assignee | ||
Comment 13•16 years ago
|
||
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.
Description
•