Micheline: Fix binary deserialization of annotations

Fixes #262
This commit is contained in:
Alain Mebsout 2018-07-13 15:50:48 +02:00 committed by Benjamin Canou
parent 3ca1fc9509
commit a7eb0cdf36
2 changed files with 17 additions and 8 deletions

View File

@ -581,6 +581,13 @@ bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pa
bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 400 (Some 1232)) (Pair 400 (Some 1232)))'
bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 401 (Some 0)) (Pair 400 (Some 1232)))'
# Test for issue #262
tee /tmp/bug_262.tz <<EOF
{ parameter unit ; storage unit ; code { DROP ; LAMBDA unit unit {} ; UNIT ; EXEC ; NIL operation ; PAIR } }
EOF
init_with_transfer /tmp/bug_262.tz $key1 'Unit' 1 bootstrap1
assert_balance bug_262 "1 ꜩ"
printf "\nEnd of test\n"
show_logs="no"

View File

@ -171,14 +171,16 @@ let canonical_encoding ~variant prim_encoding =
(fun args -> Seq (0, args)) in
let annots_encoding =
let split s =
let annots = String.split_on_char ' ' s in
List.iter (fun a ->
if String.length a > 255 then failwith "Oversized annotation"
) annots;
if String.concat " " annots <> s then
failwith "Invalid annotation string, \
must be a sequence of valid annotations with spaces" ;
annots in
if s = "" then []
else
let annots = String.split_on_char ' ' s in
List.iter (fun a ->
if String.length a > 255 then failwith "Oversized annotation"
) annots;
if String.concat " " annots <> s then
failwith "Invalid annotation string, \
must be a sequence of valid annotations with spaces" ;
annots in
splitted
~json:(list (Bounded.string 255))
~binary:(conv (String.concat " ") split string) in