Reject all overlong UTF8 sequences.
This commit is contained in:
1 parent
ff48bd6ec5
commit
8b1b503609
3 files changed
+8
-2
No files matched your search
+2
-2
@@ -6,13 +6,12 @@ mask = lambda n: (1 << n) - 1
|
||||
|
||||
|
||||
def print_table(type, name, t):
|
||||
assert len(t) == 256
|
||||
print("static const %s %s[] =" % (type, name))
|
||||
first = True
|
||||
for i in range(0,len(t),16):
|
||||
print ((" {" if i == 0 else " ") +
|
||||
", ".join("0x%02x"%n for n in t[i:i+16]) +
|
||||
("," if i + 16 < 256 else "};"))
|
||||
("," if i + 16 < len(t) else "};"))
|
||||
|
||||
|
||||
def utf8info(c):
|
||||
@@ -30,3 +29,4 @@ print("#define UTF8_CONTINUATION_BYTE ((unsigned char)255)")
|
||||
|
||||
print_table("unsigned char", "utf8_coding_length", table(0))
|
||||
print_table("unsigned char", "utf8_coding_bits", table(1))
|
||||
print_table("int", "utf8_first_codepoint", [0, 0x0, 0x80, 0x800, 0x10000])
|
||||
Reference in new issue
Block a user