Skip to content

Commit 6fef659

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 fcf3484 commit 6fef659

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
@@ -1638,11 +1638,13 @@ consumers of content generated with <a>GBK</a>'s <a for=/>encoder</a>.
16381638
<li><p>Set <a>gb18030 first</a>, <a>gb18030 second</a>, and
16391639
<a>gb18030 third</a> to 0x00.
16401640

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

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

16481650
<li>

0 commit comments

Comments
 (0)