Skip to content

Commit 6dd1859

Browse files
author
blake2-ppc
committed
std: Disallow bytes 0xC0, 0xC1 (192, 193) in utf-8
Bytes 0xC0, 0xC1 can only be used to start 2-byte codepoint encodings, that are 'overlong encodings' of codepoints below 128. The reference given in a comment -- https://tools.ietf.org/html/rfc3629 -- does in fact already exclude these bytes, so no additional comment should be needed in the code.
1 parent 576f395 commit 6dd1859

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libstd/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ static UTF8_CHAR_WIDTH: [u8, ..256] = [
712712
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0x9F
713713
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
714714
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xBF
715-
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
715+
0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
716716
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // 0xDF
717717
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, // 0xEF
718718
4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0, // 0xFF

0 commit comments

Comments
 (0)