spnda / fastgltf

A modern C++17 glTF 2.0 library focused on speed, correctness, and usability
https://fastgltf.readthedocs.io/v0.8.x/
MIT License
315 stars 48 forks source link

Process escaped sequences in URIs from glTF files. #28

Closed DragonJoker closed 1 year ago

DragonJoker commented 1 year ago

Currently the glTF sample model "Box With Spaces" isn't parsed due to escaped spaces in URIs. This glTF file uses both URIs with spaces and URIs with escaped spaces (using %20).

spnda commented 1 year ago

So, I did have percent encoding implemented in the URI class, but was not calling the function in the URI::operator=(const URIView& view) operator, which was used internally while parsing. I have now changed that operator to always try and decode and then parse the URI again. (I think) this should now cover all cases in the URI class that it should always contain properly decoded URIs. I've also added a test case with that asset.

However, it should probably be noted somewhere that if someone should create a URIView from a std::string_view that contains percent-encoded chars, that will not be decoded by the view. Data coming directly from fastgltf should always be properly decoded, though.