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

JSON must use UTF-8 encoding without BOM #1345

Closed
bghgary opened this issue May 22, 2018 · 6 comments
Closed

JSON must use UTF-8 encoding without BOM #1345

bghgary opened this issue May 22, 2018 · 6 comments

Comments

@bghgary
Copy link
Contributor

bghgary commented May 22, 2018

@lexaknyazev

https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#json-encoding

  1. JSON must use UTF-8 encoding without BOM.

Is there a specific reason why we restrict it to "without BOM"? Can we add some validation to the validator?

#831 seems to talk about this, but I see no discussion on BOM.

@lexaknyazev
Copy link
Member

From RFC-7159 (JSON), section 8.1

Implementations MUST NOT add a byte order mark to the beginning of a JSON text. In the interests of interoperability, implementations that parse JSON texts MAY ignore the presence of a byte order mark rather than treating it as an error.

Also it allows loaders to not support full UTF-8 charset because all glTF-defined strings are ASCII-representable.

The validator will refuse to load an asset starting with BOM in some cases, I'll investigate to make that consistent across all builds/inputs.

@bghgary
Copy link
Contributor Author

bghgary commented May 22, 2018

The validator will refuse to load an asset starting with BOM in some cases

http://github.khronos.org/glTF-Validator/ doesn't fail.

Here is an asset with a UTF-8 BOM:
AssetWithBOM.zip

@lexaknyazev
Copy link
Member

@bghgary What kind of validation result would you prefer?

  • refuse to read an asset as if JSON is broken; or
  • read as usual but issue an additional error.

@bghgary
Copy link
Contributor Author

bghgary commented May 28, 2018

I would prefer the second if it's not too much trouble.

@lexaknyazev
Copy link
Member

The validator update will land today. Do we need any spec changes?

@bghgary
Copy link
Contributor Author

bghgary commented May 31, 2018

Do we need any spec changes?

I don't think we should remove the restriction from the spec, but it might be useful to have an implementation note similar to what you referenced earlier in RFC-7159 (JSON), section 8.1.

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

No branches or pull requests

2 participants