… | |
… | |
27 | # define SvREFCNT_inc_NN(sv) SvREFCNT_inc (sv) |
27 | # define SvREFCNT_inc_NN(sv) SvREFCNT_inc (sv) |
28 | #endif |
28 | #endif |
29 | #ifndef SvREFCNT_dec_NN |
29 | #ifndef SvREFCNT_dec_NN |
30 | # define SvREFCNT_dec_NN(sv) SvREFCNT_dec (sv) |
30 | # define SvREFCNT_dec_NN(sv) SvREFCNT_dec (sv) |
31 | #endif |
31 | #endif |
|
|
32 | |
|
|
33 | // perl's is_utf8_string interprets len=0 as "calculate len", but we want it to mean 0 |
|
|
34 | #define cbor_is_utf8_string(str,len) (!(len) || is_utf8_string ((str), (len))) |
32 | |
35 | |
33 | // known major and minor types |
36 | // known major and minor types |
34 | enum cbor_type |
37 | enum cbor_type |
35 | { |
38 | { |
36 | MAJOR_SHIFT = 5, |
39 | MAJOR_SHIFT = 5, |
… | |
… | |
987 | |
990 | |
988 | WANT (len); |
991 | WANT (len); |
989 | dec->cur += len; |
992 | dec->cur += len; |
990 | |
993 | |
991 | if (ecb_expect_false (dec->cbor.flags & F_VALIDATE_UTF8)) |
994 | if (ecb_expect_false (dec->cbor.flags & F_VALIDATE_UTF8)) |
992 | if (!is_utf8_string ((U8 *)key, len)) |
995 | if (!cbor_is_utf8_string ((U8 *)key, len)) |
993 | ERR ("corrupted CBOR data (invalid UTF-8 in map key)"); |
996 | ERR ("corrupted CBOR data (invalid UTF-8 in map key)"); |
994 | |
997 | |
995 | hv_store (hv, key, -len, decode_sv (dec), 0); |
998 | hv_store (hv, key, -len, decode_sv (dec), 0); |
996 | |
999 | |
997 | return; |
1000 | return; |
… | |
… | |
1126 | } |
1129 | } |
1127 | |
1130 | |
1128 | if (utf8) |
1131 | if (utf8) |
1129 | { |
1132 | { |
1130 | if (ecb_expect_false (dec->cbor.flags & F_VALIDATE_UTF8)) |
1133 | if (ecb_expect_false (dec->cbor.flags & F_VALIDATE_UTF8)) |
1131 | if (!is_utf8_string (SvPVX (sv), SvCUR (sv))) |
1134 | if (!cbor_is_utf8_string (SvPVX (sv), SvCUR (sv))) |
1132 | ERR ("corrupted CBOR data (invalid UTF-8 in text string)"); |
1135 | ERR ("corrupted CBOR data (invalid UTF-8 in text string)"); |
1133 | |
1136 | |
1134 | SvUTF8_on (sv); |
1137 | SvUTF8_on (sv); |
1135 | } |
1138 | } |
1136 | |
1139 | |