jkuhlmann / cgltf

:diamond_shape_with_a_dot_inside: Single-file glTF 2.0 loader and writer written in C99
MIT License
1.46k stars 135 forks source link

Add function for decoding escaped json strings #165

Closed pezcode closed 3 years ago

pezcode commented 3 years ago

See https://github.com/jkuhlmann/cgltf/issues/163 for background information.

The new function is called cgltf_decode_string and decodes all valid JSON escape sequences in-place. There are some assumptions in the code about the validity of escape sequences which were all previously checked by jsmn (or json parsing fails). Using this function with any string not from cgltf_data might break in funny ways, but I don't see the point of checking the same thing twice.

I also added tests for cgltf_decode_string as well as cgltf_decode_uri and verified that they pass under MSVC 2019 and Clang 10.

jkuhlmann commented 3 years ago

Thanks for the PR! Can you fix the failed test on Ubuntu? https://github.com/jkuhlmann/cgltf/pull/165/checks?check_run_id=3625925333

pezcode commented 3 years ago

I hope that fixes it 🙇

A bit mysterious why I didn't get those errors when compiling through test_all.py with the same GCC version as CI is using.