Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow URLs with non-ASCII characters to be parsed #1063

Closed
wants to merge 2 commits into from

Conversation

azrogers
Copy link
Contributor

As described in #973, glTFs that include URIs with non-ASCII characters in them don't currently work with Cesium Native. That's because the library we use for URI parsing, uriparser, follows the RFC 3986 standard. According to RFC 3986, only ASCII characters are allowed in URLs, and all other characters must be escaped. Unicode support came later, in RFC 3987 and now the WhatWG URL specification which seems to be the modern standard browsers aim to support. The glTF spec allows Unicode characters in URIs "as-is," meaning a strictly RFC 3986-compliant parser won't do the job. One option would be to substitute a different, WhatWG-compliant parser in its place - but as I described in this comment, this introduces more problems than it solves.

Instead, the solution I went with was to encode all non-ASCII characters in the string before passing it to uriparser, then decoding them again before returning from the method. This seems to work flawlessly - uriparser gets the RFC 3986-compliant URLs it expects, and the user gets the WhatWG-compliant URLs they expect. Unfortunately, this solution does introduce an extra layer of string copies into URL parsing. This isn't ideal, but considering URLs are usually fairly short, I think it's a worthwhile tradeoff to gain this compliance with the glTF spec.

@azrogers azrogers closed this Jan 17, 2025
@azrogers
Copy link
Contributor Author

Closed in favor of #1072.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant