Explorar o código

raise an error when the code point is greater than 0x10FFFF

Ryusei Yamaguchi %!s(int64=11) %!d(string=hai) anos
pai
achega
3f0bf93c50
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      ast.ml

+ 3 - 1
ast.ml

@@ -625,7 +625,9 @@ let unescape s =
 					      _ -> try
 						assert (s.[i+1] = '{');
 						let l = String.index_from s (i+3) '}' - (i+2) in
-						(int_of_string ("0x" ^ String.sub s (i+2) l), l+2)
+						let u = int_of_string ("0x" ^ String.sub s (i+2) l) in
+						assert (u <= 0x10FFFF);
+						(u, l+2)
 					      with _ -> raise Exit) in
 					let ub = UTF8.Buf.create 0 in
 					UTF8.Buf.add_char ub (UChar.uchar_of_int u);