From 4b61550af01cb74ebdc116cecf6aae1264e906bc Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Thu, 14 Mar 2024 15:11:35 -0700 Subject: [PATCH 1/4] Editorial: drop redundant "is a string" checks --- spec.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec.html b/spec.html index b644cd1..dd1fd5f 100644 --- a/spec.html +++ b/spec.html @@ -22,7 +22,6 @@

Uint8Array.prototype.toBase64 ( [ _options_ ] )

1. Let _opts_ be ? GetOptionsObject(_options_). 1. Let _alphabet_ be ? Get(_opts_, *"alphabet"*). 1. If _alphabet_ is *undefined*, set _alphabet_ to *"base64"*. - 1. If _alphabet_ is not a String, throw a *TypeError* exception. 1. If _alphabet_ is neither *"base64"* nor *"base64url"*, throw a *TypeError* exception. 1. Let _toEncode_ be ? GetUint8ArrayBytes(_O_). 1. If _alphabet_ is *"base64"*, then @@ -56,7 +55,6 @@

Uint8Array.fromBase64 ( _string_ [ , _options_ ] )

1. Let _opts_ be ? GetOptionsObject(_options_). 1. Let _alphabet_ be ? Get(_opts_, *"alphabet"*). 1. If _alphabet_ is *undefined*, set _alphabet_ to *"base64"*. - 1. If _alphabet_ is not a String, throw a *TypeError* exception. 1. If _alphabet_ is neither *"base64"* nor *"base64url"*, throw a *TypeError* exception. 1. Let _lastChunkHandling_ be ? Get(_opts_, *"lastChunkHandling"*). 1. If _lastChunkHandling_ is *undefined*, set _lastChunkHandling_ to *"loose"*. @@ -78,7 +76,6 @@

Uint8Array.prototype.setFromBase64 ( _string_ [ , _options_ ] )

1. Let _opts_ be ? GetOptionsObject(_options_). 1. Let _alphabet_ be ? Get(_opts_, *"alphabet"*). 1. If _alphabet_ is *undefined*, set _alphabet_ to *"base64"*. - 1. If _alphabet_ is not a String, throw a *TypeError* exception. 1. If _alphabet_ is neither *"base64"* nor *"base64url"*, throw a *TypeError* exception. 1. Let _lastChunkHandling_ be ? Get(_opts_, *"lastChunkHandling"*). 1. If _lastChunkHandling_ is *undefined*, set _lastChunkHandling_ to *"loose"*. From 8c7a6ba50d23d2b5dcacfe18e8c8b4edcf550cfb Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Thu, 14 Mar 2024 15:14:27 -0700 Subject: [PATCH 2/4] Editorial: consistently use TypedArrayLength --- spec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.html b/spec.html index dd1fd5f..f1dd088 100644 --- a/spec.html +++ b/spec.html @@ -82,7 +82,7 @@

Uint8Array.prototype.setFromBase64 ( _string_ [ , _options_ ] )

1. If _lastChunkHandling_ is not one of *"loose"*, *"strict"*, or *"stop-before-partial"*, throw a *TypeError* exception. 1. Let _taRecord_ be MakeTypedArrayWithBufferWitnessRecord(_into_, ~seq-cst~). 1. If IsTypedArrayOutOfBounds(_taRecord_) is *true*, throw a *TypeError* exception. - 1. Let _byteLength_ be TypedArrayByteLength(_taRecord_). + 1. Let _byteLength_ be TypedArrayLength(_taRecord_). 1. Let _maxLength_ be _byteLength_. 1. Let _result_ be ? FromBase64(_string_, _alphabet_, _lastChunkHandling_, _maxLength_). 1. Let _bytes_ be _result_.[[Bytes]]. @@ -117,7 +117,7 @@

Uint8Array.prototype.setFromHex ( _string_ )

1. If _string_ is not a String, throw a *TypeError* exception. 1. Let _taRecord_ be MakeTypedArrayWithBufferWitnessRecord(_into_, ~seq-cst~). 1. If IsTypedArrayOutOfBounds(_taRecord_) is *true*, throw a *TypeError* exception. - 1. Let _byteLength_ be TypedArrayByteLength(_taRecord_). + 1. Let _byteLength_ be TypedArrayLength(_taRecord_). 1. Let _maxLength_ be _byteLength_. 1. Let _result_ be ? FromHex(_string_, _maxLength_). 1. Let _bytes_ be _result_.[[Bytes]]. From ba172cf26a054f4652a6abbc617260b2426a475a Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Thu, 14 Mar 2024 15:15:30 -0700 Subject: [PATCH 3/4] Editorial: drop unnecessary intermediate variable --- spec.html | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spec.html b/spec.html index f1dd088..d8b691b 100644 --- a/spec.html +++ b/spec.html @@ -83,8 +83,7 @@

Uint8Array.prototype.setFromBase64 ( _string_ [ , _options_ ] )

1. Let _taRecord_ be MakeTypedArrayWithBufferWitnessRecord(_into_, ~seq-cst~). 1. If IsTypedArrayOutOfBounds(_taRecord_) is *true*, throw a *TypeError* exception. 1. Let _byteLength_ be TypedArrayLength(_taRecord_). - 1. Let _maxLength_ be _byteLength_. - 1. Let _result_ be ? FromBase64(_string_, _alphabet_, _lastChunkHandling_, _maxLength_). + 1. Let _result_ be ? FromBase64(_string_, _alphabet_, _lastChunkHandling_, _byteLength_). 1. Let _bytes_ be _result_.[[Bytes]]. 1. Let _written_ be the length of _bytes_. 1. NOTE: FromBase64 does not invoke any user code, so the ArrayBuffer backing _into_ cannot have been detached or shrunk. @@ -118,8 +117,7 @@

Uint8Array.prototype.setFromHex ( _string_ )

1. Let _taRecord_ be MakeTypedArrayWithBufferWitnessRecord(_into_, ~seq-cst~). 1. If IsTypedArrayOutOfBounds(_taRecord_) is *true*, throw a *TypeError* exception. 1. Let _byteLength_ be TypedArrayLength(_taRecord_). - 1. Let _maxLength_ be _byteLength_. - 1. Let _result_ be ? FromHex(_string_, _maxLength_). + 1. Let _result_ be ? FromHex(_string_, _byteLength_). 1. Let _bytes_ be _result_.[[Bytes]]. 1. Let _written_ be the length of _bytes_. 1. NOTE: FromHex does not invoke any user code, so the ArrayBuffer backing _into_ cannot have been detached or shrunk. From 8913f8a85250e45d8a029c4ffe827d407012e720 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Thu, 14 Mar 2024 15:20:39 -0700 Subject: [PATCH 4/4] Editorial: tweak wording of "standard base64 alphabet" --- spec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.html b/spec.html index d8b691b..0044dd3 100644 --- a/spec.html +++ b/spec.html @@ -220,7 +220,7 @@

-

The standard base64 alphabet is a List whose elements are the code points corresponding to every letter and number in the Unicode Basic Latin block along with *"+"* and *"/"*; that is, it is StringToCodePoints(*"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"*).

+

The standard base64 alphabet is the String whose elements are the code units corresponding to every letter and number in the Unicode Basic Latin block along with *"+"* and *"/"*; that is, it is *"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"*.

1. Let _chunkLength_ be the length of _chunk_. 1. If _chunkLength_ is 2, then @@ -308,7 +308,7 @@

1. If _char_ is either *"+"* or *"/"*, throw a *SyntaxError* exception. 1. Else if _char_ is *"-"*, set _char_ to *"+"*. 1. Else if _char_ is *"_"*, set _char_ to *"/"*. - 1. If _char_ is not an element of the standard base64 alphabet, throw a *SyntaxError* exception. + 1. If the sole code unit of _char_ is not an element of the standard base64 alphabet, throw a *SyntaxError* exception. 1. Let _remaining_ be _maxLength_ - the length of _bytes_. 1. If _remaining_ = 1 and _chunkLength_ = 2, or if _remaining_ = 2 and _chunkLength_ = 3, then 1. Return the Record { [[Read]]: _read_, [[Bytes]]: _bytes_ }.