Bug 104358 - base64DecodeInternal() is not conforming to HTML5(window.atob) spec.
Summary: base64DecodeInternal() is not conforming to HTML5(window.atob) spec.
Status: RESOLVED DUPLICATE of bug 118898
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-07 02:58 PST by Sanghyun Park
Modified: 2015-05-11 02:11 PDT (History)
10 users (show)

See Also:


Attachments
Initial patch! (5.71 KB, patch)
2013-01-29 00:34 PST, Sanghyun Park
ossy: review-
ossy: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sanghyun Park 2012-12-07 02:58:06 PST
base64DecodeInternal() is not conforming to HTML5(window.atob) spec.

Window.atob has not been implemented in accordance with base64 spec(http://www.w3.org/TR/html5/webappapis.html#atob).
4. If the length of input divides by 4 leaving no remainder, then: if input ends with one or two "=" (U+003D) characters, remove them from input. (in spec)
6. If input contains a character that is not in the following list of characters and character ranges, throw an InvalidCharacterError exception and abort these steps (in spec)
   - Currently in WebKit, if input invalid charater, did not throw an InvalidCharacterError exception and abort.

This issue is reproducible at w3c approved test site (http://w3c-test.org/html/tests/approved/base64.html).

So, I will upload the patch as soon as possible.
Comment 1 Glenn Adams 2012-12-07 07:20:39 PST
how does the HTML5 specified behavior compare with other implementations? FF, IE, etc?
Comment 2 Sanghyun Park 2012-12-10 07:32:23 PST
(In reply to comment #1)
> how does the HTML5 specified behavior compare with other implementations? FF, IE, etc?

In case of WebKit, result of w3c approved test site is "350 pass/18 fail".

On the other hand, firefox result is 366 pass / 2 fail.
- 2 fails are TC error, so firefox supports the spec, perfectly.

Opera is also better than WebKit.(Result : 363 pass / 5 fail).
Comment 3 Glenn Adams 2012-12-10 07:37:35 PST
in the case of tests where one or more other browsers also fail, then care should be given to the validity of the test in question; some evaluation/discussion may be needed before implementing changes to pass the test; in other words, don't simply assume that the w3c tests are always valid
Comment 4 Sanghyun Park 2012-12-10 08:53:09 PST
Thanks for your kind concern. I have tried double-checking to make sure about mismatching between TC and Spec.
Failed 14 test cases which are proper. However, 2 failed TCs have below bugs.

Let atob("ab="). (- this test is contained the "http://w3c-test.org/html/tests/approved/base64.htm")

According to No. 4 of aboved spec, 
Because length of "ab=" is not divisible by 4, cannot remove the "=".

According to No. 6 of aboved spec, 
"=" is not in the following list of characters and character ranges("+" (U+002B), "/" (U+002F), ASCII digits, uppercase ASCII letters and lowercase ASCII letters).
So,should throw an InvalidCharacterError exception and abort.

but in Webkit, do not following No. 4 spec and always remove ends with "=" characters, so do not throw an error.
Comment 5 Sanghyun Park 2013-01-29 00:34:47 PST
Created attachment 185186 [details]
Initial patch!
Comment 6 Benjamin Poulain 2013-01-29 00:43:17 PST
(In reply to comment #3)
> in the case of tests where one or more other browsers also fail, then care should be given to the validity of the test in question; some evaluation/discussion may be needed before implementing changes to pass the test; in other words, don't simply assume that the w3c tests are always valid

This is an important point. Thanks for pointing that out.
Comment 7 Csaba Osztrogonác 2015-05-11 02:11:25 PDT

*** This bug has been marked as a duplicate of bug 118898 ***