CesiumGS / cesium-native

Apache License 2.0
438 stars 215 forks source link

Can't load glTF URIs with unicode characters #973

Open lilleyse opened 3 weeks ago

lilleyse commented 3 weeks ago

According to the glTF URIs section:

Paths with non-ASCII characters MAY be written as-is, with JSON string escaping, or with percent-encoding; all these options are valid. For example, the following three paths point to the same resource:

{
   "images": [
       {
          "uri": "grande_sphère.png"
       },
       {
           "uri": "grande_sph\u00E8re.png"
       },
       {
           "uri": "grande_sph%C3%A8re.png"
       }
   ]
}

But when I try to use GltfReader to load a glTF with a URI to 🐶.bin I get a runtime error:

std::runtime_error caught: GET `🐶.bin` failed: Couldn't resolve host name

🐶.gltf.zip

This may be a limitation in uriparser which only parses RFC 3986 URIs which are ASCII-based. It does not handle RFC 3987 IRIs which allow Unicode characters verbatim.

kring commented 3 weeks ago

Your explanation makes sense to me @lilleyse. I wonder if there's a better library for our purposes than uriparser. I couldn't find one when I originally selected it for cesium-native, but that was over four years ago now.