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 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)))' 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" printf "\nEnd of test\n"
show_logs="no" show_logs="no"

View File

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