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

Encoding of non-UTF-8 `String _ values, fail earlier? #46

Open
smondet opened this issue May 26, 2021 · 0 comments
Open

Encoding of non-UTF-8 `String _ values, fail earlier? #46

smondet opened this issue May 26, 2021 · 0 comments

Comments

@smondet
Copy link

smondet commented May 26, 2021

Encoded arbitrary strings can fail to be parsed back:

# let teeshow s = Printf.printf "-> %S\n%!" s; s;;
val teeshow : string -> string = <fun>
# let x = Ezjsonm.(value_from_string (value_to_string (`String "\xbe") |> teeshow));;
-> "\"\190\""
Exception:
Ezjsonm.Parse_error (`Null,
 "JSON.of_buffer illegal bytes in character stream (BE)").

In value_to_src `String _ Ezjsonm.values are passed directly to Jsonm.encode e (`Lexeme l).

The Jsonm documentation says:

Only the UTF-8 encoding scheme is supported. The strings of encoded `Name and `String lexemes are assumed to be immutable and must be UTF-8 encoded, this is not checked by the module.

Should Ezjsonm fail earlier, at encoding time?

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

1 participant