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

Where do we enforce UTF-8 JSON? #67

Closed
wking opened this issue May 13, 2016 · 1 comment · Fixed by #70
Closed

Where do we enforce UTF-8 JSON? #67

wking opened this issue May 13, 2016 · 1 comment · Fixed by #70

Comments

@wking
Copy link
Contributor

wking commented May 13, 2016

Spun off from #66, where “All configuration JSON MUST be encoded in UTF-8” is checked. And it seems to be:

$ ./ocitools generate
$ iconv -f UTF-8 -t UTF-16 config.json -o config-16.json
$ mv config-16.json config.json
$ file config.json
config.json: Little-endian UTF-16 Unicode text
$ ./ocitools validate --path .
FATA[0000] invalid character 'ÿ' looking for beginning of value

But I can't find Go docs on what input encodings are supported or UTF references in ocitools:

$ git grep -i utf origin/master
Binary file origin/master:rootfs.tar.gz matches

The Go docs reference RFC 4627, and the RFC explains how to detect the encoding, but maybe Go doesn't support that yet? Can someone with more Go+JSON experience explain how this works?

@liangchenye
Copy link
Member

@wking my mistake, I just update #66, ocitools has not verify utf8 encoding yet.
I test it locally by using https://golang.org/pkg/unicode/utf8/#Valid. It works well.

In my test, I add a Chinese word "/主目录" to CWD field in config.json and convert it to gb18030.
utf8.Valid returns false.

liangchenye added a commit to liangchenye/ocitools that referenced this issue May 18, 2016
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 a pull request may close this issue.

2 participants