not-fl3 / nanoserde

Serialisation library with zero dependencies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DeJson string deserialization accepts various invalid JSON strings

thomcc opened this issue · comments

After #10 lands, there are two issues with DeJson's string deserialization code:

  1. Various invalid escapes to get through. Any character that appears after a backslash is allowed more or less.
  2. Various ASCII control codes are allowed in JSON strings in unescaped form, but it should be an error if any below U+0020 appear without being escaped. (E.g.

    nanoserde/src/serde_json.rs

    Lines 517 to 519 in 0704316

    '\0' => {
    return Err(self.err_parse("string"));
    }
    and

    nanoserde/src/serde_json.rs

    Lines 524 to 526 in 0704316

    if self.cur == '\0' {
    return Err(self.err_parse("string"));
    }
    should be adjusted so that it's any character between ('\u{0}'..'\u{20}') that causes an error).

I don't really care a ton about either of these personally, though.