Skip to content

Commit 93e057b

Browse files
committed
gb18030 encoder: unwind from fourth byte when it's not a digit
Instead of always unwinding if there’s no code point when consuming the fourth byte, only unwind when the fourth byte is not an ASCII digit. This does mean that ASCII digits can be masked, but since ASCII digits are not used as delimiter in any format this is highly unlikely to be used in any attacks (and also matches existing implementations better). Fixes #110.
1 parent e43b030 commit 93e057b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

encoding.bs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,11 +1640,13 @@ consumers of content generated with <a>GBK</a>'s <a for=/>encoder</a>.
16401640
<li><p>Set <a>gb18030 first</a>, <a>gb18030 second</a>, and
16411641
<a>gb18030 third</a> to 0x00.
16421642

1643-
<li><p>If <var>code point</var> is null,
1644-
<a>prepend</a> <var>buffer</var> to
1645-
<var>stream</var> and return <a>error</a>.
1643+
<li><p>If <var>code point</var> is non-null, return a code point whose value is
1644+
<var>code point</var>.
16461645

1647-
<li><p>Return a code point whose value is <var>code point</var>.
1646+
<li><p>If <var>byte</var> is not in the range 0x30 to 0x39, inclusive, <a>prepend</a>
1647+
<var>buffer</var> to <var>stream</var>.
1648+
1649+
<li><p>Return <a>error</a>.
16481650
</ol>
16491651

16501652
<li>

0 commit comments

Comments
 (0)