|
143 | 143 |
|
144 | 144 | .parse-error-table td > p:first-child { margin-top: 0; } |
145 | 145 |
|
146 | | - #base64-table { |
147 | | - white-space: nowrap; |
148 | | - font-size: 0.6em; |
149 | | - column-width: 6em; |
150 | | - column-count: 5; |
151 | | - column-gap: 1em; |
152 | | - -moz-column-width: 6em; |
153 | | - -moz-column-count: 5; |
154 | | - -moz-column-gap: 1em; |
155 | | - -webkit-column-width: 6em; |
156 | | - -webkit-column-count: 5; |
157 | | - -webkit-column-gap: 1em; |
158 | | - } |
159 | | - #base64-table thead { display: none; } |
160 | | - #base64-table * { border: none; } |
161 | | - #base64-table tbody td:first-child:after { content: ':'; } |
162 | | - #base64-table tbody td:last-child { text-align: right; } |
163 | | - |
164 | 146 | #named-character-references-table { |
165 | 147 | white-space: nowrap; |
166 | 148 | font-size: 0.6em; |
@@ -2450,6 +2432,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute |
2450 | 2432 | <dfn data-x="set append" data-x-href="https://infra.spec.whatwg.org/#set-append">append</dfn></li> |
2451 | 2433 | <li>The <dfn data-x-href="https://infra.spec.whatwg.org/#struct">struct</dfn> specification type and the associated definition for |
2452 | 2434 | <dfn data-x="struct item" data-x-href="https://infra.spec.whatwg.org/#struct-item">item</dfn></li> |
| 2435 | + <li>The <dfn data-x-href="https://infra.spec.whatwg.org/#forgiving-base64-encode">forgiving-base64 encode</dfn> and |
| 2436 | + <dfn data-x-href="https://infra.spec.whatwg.org/#forgiving-base64-decode">forgiving-base64 decode</dfn> algorithms</li> |
2453 | 2437 | <li><dfn data-x-href="https://infra.spec.whatwg.org/#html-namespace">HTML namespace</dfn></li> |
2454 | 2438 | <li><dfn data-x-href="https://infra.spec.whatwg.org/#mathml-namespace">MathML namespace</dfn></li> |
2455 | 2439 | <li><dfn data-x-href="https://infra.spec.whatwg.org/#svg-namespace">SVG namespace</dfn></li> |
@@ -90025,7 +90009,7 @@ interface <dfn>WindowOrWorkerGlobalScope</dfn> { |
90025 | 90009 |
|
90026 | 90010 | // base64 utility methods |
90027 | 90011 | DOMString <span data-x="dom-btoa">btoa</span>(DOMString data); |
90028 | | - DOMString <span data-x="dom-atob">atob</span>(DOMString data); |
| 90012 | + ByteString <span data-x="dom-atob">atob</span>(DOMString data); |
90029 | 90013 |
|
90030 | 90014 | // timers |
90031 | 90015 | long <span data-x="dom-setTimeout">setTimeout</span>(<span>TimerHandler</span> handler, optional long timeout = 0, any... arguments); |
@@ -90114,180 +90098,23 @@ document.body.appendChild(frame)</pre> |
90114 | 90098 | <p>The <dfn data-x="dom-btoa"><code id="dom-windowbase64-btoa">btoa(<var>data</var>)</code></dfn> |
90115 | 90099 | method must throw an <span>"<code>InvalidCharacterError</code>"</span> <code>DOMException</code> |
90116 | 90100 | if <var>data</var> contains any character whose code point is greater than U+00FF. Otherwise, the |
90117 | | - user agent must convert <var>data</var> to a sequence of octets whose <var>n</var>th octet is the |
90118 | | - eight-bit representation of the code point of the <var>n</var>th character of <var>data</var>, and |
90119 | | - then must apply the base64 algorithm to that sequence of octets, and return the result. <ref |
90120 | | - spec=RFC4648><!--base64--></p> |
90121 | | - <!-- Aryeh says: This seems to be what all browsers do as of January 2011 (except IE, which |
90122 | | - doesn't support these functions at all). --> |
90123 | | - |
| 90101 | + user agent must convert <var>data</var> to a byte sequence whose <var>n</var>th byte is the |
| 90102 | + eight-bit representation of the <var>n</var>th code point of <var>data</var>, and then must apply |
| 90103 | + <span>forgiving-base64 encode</span> to that byte sequence and return the result.</p> |
90124 | 90104 |
|
90125 | 90105 | <p>The <dfn data-x="dom-atob"><code id="dom-windowbase64-atob">atob(<var>data</var>)</code></dfn> |
90126 | 90106 | method, when invoked, must run the following steps:</p> |
90127 | 90107 |
|
90128 | 90108 | <ol> |
| 90109 | + <li><p>Let <var>decodedData</var> be the result of running <span>forgiving-base64 decode</span> |
| 90110 | + on <var>data</var>.</p></li> |
90129 | 90111 |
|
90130 | | - <!-- Aryeh says: Copies Firefox behavior as of January 2011 (4.0b8). WebKit is somewhat laxer, |
90131 | | - and Opera throws no exceptions at all. gsnedders reports Opera's behavior causes site-compat |
90132 | | - problems, and I figure most sites depend on Firefox if on anything, so go with that. --> |
90133 | | - |
90134 | | - <!-- Since updated to drop whitespace, based on the arguments here: |
90135 | | - https://lists.w3.org/Archives/Public/public-whatwg-archive/2011May/0207.html |
90136 | | - --> |
90137 | | - |
90138 | | - <li><p>Let <var>position</var> be a pointer into <var>data</var>, initially |
90139 | | - pointing at the start of the string.</p></li> |
90140 | | - |
90141 | | - <li><p>Remove all <span>ASCII whitespace</span> from <var>data</var>.</p></li> |
90142 | | - |
90143 | | - <li><p>If the length of <var>data</var> divides by 4 leaving no remainder, then: if |
90144 | | - <var>data</var> ends with one or two U+003D EQUALS SIGN (=) characters, remove them from |
90145 | | - <var>data</var>.</p></li> |
90146 | | - |
90147 | | - <li><p>If the length of <var>data</var> divides by 4 leaving a remainder of 1, throw an |
90148 | | - <span>"<code>InvalidCharacterError</code>"</span> <code>DOMException</code> and abort these |
90149 | | - steps.</p> |
90150 | | - |
90151 | | - <li> |
90152 | | - |
90153 | | - <p>If <var>data</var> contains a character that is not in the following list of |
90154 | | - characters and character ranges, throw an <span>"<code>InvalidCharacterError</code>"</span> |
90155 | | - <code>DOMException</code> and abort these steps:</p> |
90156 | | - |
90157 | | - <ul class="brief"> |
90158 | | - <li>U+002B PLUS SIGN (+) |
90159 | | - <li>U+002F SOLIDUS (/) |
90160 | | - <li><span>ASCII alphanumeric</span> |
90161 | | - </ul> |
90162 | | - |
90163 | | - </li> |
90164 | | - |
90165 | | - <li><p>Let <var>output</var> be a string, initially empty.</p></li> |
90166 | | - |
90167 | | - <li><p>Let <var>buffer</var> be a buffer that can have bits appended to it, initially |
90168 | | - empty.</p></li> |
90169 | | - |
90170 | | - <li> |
90171 | | - |
90172 | | - <p>While <var>position</var> does not point past the end of <var>data</var>, run these |
90173 | | - substeps:</p> |
90174 | | - |
90175 | | - <ol> |
90176 | | - |
90177 | | - <li> |
90178 | | - |
90179 | | - <p>Find the character pointed to by <var>position</var> in the first column of the |
90180 | | - following table. Let <var>n</var> be the number given in the second cell of the same |
90181 | | - row.</p> |
90182 | | - |
90183 | | - <div id="base64-table"> |
90184 | | - <table> |
90185 | | - <thead> |
90186 | | - <tr> |
90187 | | - <th>Character |
90188 | | - <th>Number |
90189 | | - <tbody> |
90190 | | - <tr><td>A<td>0 |
90191 | | - <tr><td>B<td>1 |
90192 | | - <tr><td>C<td>2 |
90193 | | - <tr><td>D<td>3 |
90194 | | - <tr><td>E<td>4 |
90195 | | - <tr><td>F<td>5 |
90196 | | - <tr><td>G<td>6 |
90197 | | - <tr><td>H<td>7 |
90198 | | - <tr><td>I<td>8 |
90199 | | - <tr><td>J<td>9 |
90200 | | - <tr><td>K<td>10 |
90201 | | - <tr><td>L<td>11 |
90202 | | - <tr><td>M<td>12 |
90203 | | - <tr><td>N<td>13 |
90204 | | - <tr><td>O<td>14 |
90205 | | - <tr><td>P<td>15 |
90206 | | - <tr><td>Q<td>16 |
90207 | | - <tr><td>R<td>17 |
90208 | | - <tr><td>S<td>18 |
90209 | | - <tr><td>T<td>19 |
90210 | | - <tr><td>U<td>20 |
90211 | | - <tr><td>V<td>21 |
90212 | | - <tr><td>W<td>22 |
90213 | | - <tr><td>X<td>23 |
90214 | | - <tr><td>Y<td>24 |
90215 | | - <tr><td>Z<td>25 |
90216 | | - <tr><td>a<td>26 |
90217 | | - <tr><td>b<td>27 |
90218 | | - <tr><td>c<td>28 |
90219 | | - <tr><td>d<td>29 |
90220 | | - <tr><td>e<td>30 |
90221 | | - <tr><td>f<td>31 |
90222 | | - <tr><td>g<td>32 |
90223 | | - <tr><td>h<td>33 |
90224 | | - <tr><td>i<td>34 |
90225 | | - <tr><td>j<td>35 |
90226 | | - <tr><td>k<td>36 |
90227 | | - <tr><td>l<td>37 |
90228 | | - <tr><td>m<td>38 |
90229 | | - <tr><td>n<td>39 |
90230 | | - <tr><td>o<td>40 |
90231 | | - <tr><td>p<td>41 |
90232 | | - <tr><td>q<td>42 |
90233 | | - <tr><td>r<td>43 |
90234 | | - <tr><td>s<td>44 |
90235 | | - <tr><td>t<td>45 |
90236 | | - <tr><td>u<td>46 |
90237 | | - <tr><td>v<td>47 |
90238 | | - <tr><td>w<td>48 |
90239 | | - <tr><td>x<td>49 |
90240 | | - <tr><td>y<td>50 |
90241 | | - <tr><td>z<td>51 |
90242 | | - <tr><td>0<td>52 |
90243 | | - <tr><td>1<td>53 |
90244 | | - <tr><td>2<td>54 |
90245 | | - <tr><td>3<td>55 |
90246 | | - <tr><td>4<td>56 |
90247 | | - <tr><td>5<td>57 |
90248 | | - <tr><td>6<td>58 |
90249 | | - <tr><td>7<td>59 |
90250 | | - <tr><td>8<td>60 |
90251 | | - <tr><td>9<td>61 |
90252 | | - <tr><td>+<td>62 |
90253 | | - <tr><td>/<td>63 |
90254 | | - </table> |
90255 | | - </div> |
90256 | | - |
90257 | | - </li> |
90258 | | - |
90259 | | - <li><p>Append to <var>buffer</var> the six bits corresponding to <var>number</var>, most significant bit first.</p></li> |
90260 | | - |
90261 | | - <li><p>If <var>buffer</var> has accumulated 24 bits, interpret them as three 8-bit |
90262 | | - big-endian numbers. Append the three characters with code points equal to those numbers to <var>output</var>, in the same order, and then empty <var>buffer</var>.</p></li> |
90263 | | - |
90264 | | - <li><p>Advance <var>position</var> by one character.</p></li> |
90265 | | - |
90266 | | - </ol> |
90267 | | - |
90268 | | - </li> |
90269 | | - |
90270 | | - <li> |
90271 | | - |
90272 | | - <p>If <var>buffer</var> is not empty, it contains either 12 or 18 bits. If it contains |
90273 | | - 12 bits, discard the last four and interpret the remaining eight as an 8-bit big-endian number. |
90274 | | - If it contains 18 bits, discard the last two and interpret the remaining 16 as two 8-bit |
90275 | | - big-endian numbers. Append the one or two characters with code points equal to those one or two |
90276 | | - numbers to <var>output</var>, in the same order.</p> |
90277 | | - |
90278 | | - <p class="note">The discarded bits mean that, for instance, <code data-x="">atob("YQ")</code> and |
90279 | | - <code data-x="">atob("YR")</code> both return "<code data-x="">a</code>".</p> |
90280 | | - |
90281 | | - </li> |
90282 | | - |
90283 | | - <li><p>Return <var>output</var>.</p></li> |
| 90112 | + <li><p>If <var>decodedData</var> is failure, then throw an |
| 90113 | + <span>"<code>InvalidCharacterError</code>"</span> <code>DOMException</code>.</p></li> |
90284 | 90114 |
|
| 90115 | + <li><p>Return <var>decodedData</var>.</p></li> |
90285 | 90116 | </ol> |
90286 | 90117 |
|
90287 | | - <!-- Note: this function is defined explicitly here because RFC4648 does not specify how to handle |
90288 | | - erroneous input, and no preexisting browser implementation simply throws an exception on all |
90289 | | - erroneous input. --> |
90290 | | - |
90291 | 90118 | </div> |
90292 | 90119 |
|
90293 | 90120 |
|
@@ -120244,9 +120071,6 @@ INSERT INTERFACES HERE |
120244 | 120071 | <dt id="refsRFC7595">[RFC7595]</dt> |
120245 | 120072 | <dd><cite><a href="https://tools.ietf.org/html/rfc7595">Guidelines and Registration Procedures for URI Schemes</a></cite>, D. Thaler, T. Hansen, T. Hardie. IETF.</dd> |
120246 | 120073 |
|
120247 | | - <dt id="refsRFC4648">[RFC4648]</dt> |
120248 | | - <dd><cite><a href="https://tools.ietf.org/html/rfc4648">The Base16, Base32, and Base64 Data Encodings</a></cite>, S. Josefsson. IETF.</dd> |
120249 | | - |
120250 | 120074 | <dt id="refsRFC5322">[RFC5322]</dt> |
120251 | 120075 | <dd><cite><a href="https://tools.ietf.org/html/rfc5322">Internet Message Format</a></cite>, P. Resnick. IETF.</dd> |
120252 | 120076 |
|
|
0 commit comments