WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 118844
68618
btoa() and atob() should stringify null to "null", not ""
https://bugs.webkit.org/show_bug.cgi?id=68618
Summary
btoa() and atob() should stringify null to "null", not ""
Aryeh Gregor
Reported
2011-09-22 07:16:02 PDT
Mozilla bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=688443
Spec:
http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#atob
It doesn't have [TreatNullAs=EmptyString], so it should be treated as "null". No one does this currently for btoa() or atob() -- Firefox 8.0a2, Chrome 15 dev, and Opera 11.50 stringify to "". (IE doesn't support the functions.) But it seems like consensus is that browsers should change here, not the spec:
http://krijnhoetmer.nl/irc-logs/whatwg/20110922#l-230
(first two lines)
http://krijnhoetmer.nl/irc-logs/whatwg/20110922#l-554
(continuation) zcorpan reports Opera has already changed, and Ms2ger says Gecko should change too. I'll update my base64 tests at the W3C to test for this.
Attachments
Patch
(4.38 KB, patch)
2011-12-06 16:10 PST
,
Alexander Færøy
no flags
Details
Formatted Diff
Diff
Patch
(4.67 KB, patch)
2011-12-07 02:14 PST
,
Alexander Færøy
eric
: review-
haraken
: commit-queue-
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Alexander Færøy
Comment 1
2011-12-06 16:10:08 PST
Created
attachment 118133
[details]
Patch
Adam Barth
Comment 2
2011-12-06 16:36:22 PST
Comment on
attachment 118133
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=118133&action=review
> Source/WebCore/page/DOMWindow.idl:252 > - DOMString btoa(in [ConvertNullToNullString,Optional=CallWithDefaultValue] DOMString string) > + DOMString btoa(in [ConvertNullStringTo=Null,Optional=CallWithDefaultValue] DOMString string)
Can we just drop the attribute? What's the default value?
Alexander Færøy
Comment 3
2011-12-07 02:14:21 PST
Created
attachment 118190
[details]
Patch
Alexander Færøy
Comment 4
2011-12-07 02:15:29 PST
Firefox is currently throwing a TypeError with not enough arguments when atob() and btoa() is called with no arguments. My patch above should fix that as well.
Kentaro Hara
Comment 5
2012-01-25 18:21:27 PST
Comment on
attachment 118190
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=118190&action=review
The change looks OK to me.
> Source/WebCore/ChangeLog:5 > +
Would you add some explanation about this change? At least the link to the spec, please.
> LayoutTests/ChangeLog:5 > +
Would you add some explanation about this change? At least the link to the spec, please.
> LayoutTests/fast/dom/Window/atob-btoa.html:25 > +shouldBe('window.btoa(null)', '"bnVsbA=="'); > shouldBe('window.btoa(undefined)', '"dW5kZWZpbmVk"');
Shall we add the following test cases? shouldBe('window.btoa("null")', '"bnVsbA=="'); shouldBe('window.btoa("undefined")', '"dW5kZWZpbmVk"');
> LayoutTests/fast/dom/Window/atob-btoa.html:35 > shouldThrow('window.atob()'); // 'undefined'
Can you remove the comment "// 'undefined'"?
> LayoutTests/fast/dom/Window/atob-btoa.html:38 > +shouldBe('window.atob(null)', '"Âée"'); > shouldThrow('window.atob(undefined)');
Shall we add the following test cases? shouldBe('window.atob("null")', '"Âée"'); shouldThrow('window.atob("undefined")');
Eric Seidel (no email)
Comment 6
2012-02-13 10:05:36 PST
Comment on
attachment 118190
[details]
Patch r-, per Kentaro's comments.
Alexey Shvayka
Comment 7
2021-04-24 11:59:00 PDT
(In reply to Alexander Færøy from
comment #4
)
> Firefox is currently throwing a TypeError with not enough arguments when > atob() and btoa() is called with no arguments. My patch above should fix > that as well.
Thank you for the patch! atob() / btoa() argument was made mandatory in
r152859
. *** This bug has been marked as a duplicate of
bug 118844
***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug