Key-value pairs *must* be strings with size 1. */
| 427 | } |
| 428 | /* Key-value pairs *must* be strings with size 1. */ |
| 429 | static inline const jsmntok_t * |
| 430 | validate_jsmn_keyvalue(const char *buf, |
| 431 | const jsmntok_t *p, |
| 432 | const jsmntok_t *end, |
| 433 | bool *valid) |
| 434 | { |
| 435 | if (p >= end) { |
| 436 | *valid = false; |
| 437 | return p; |
| 438 | } |
| 439 | |
| 440 | /* Check key. |
| 441 | * |
| 442 | * JSMN parses the syntax `"key": "value"` as a |
| 443 | * JSMN_STRING of size 1, containing the value |
| 444 | * datum as a sub-datum. |
| 445 | * |
| 446 | * Thus, keys in JSON objects are really strings |
| 447 | * that "contain" the value, thus we check if |
| 448 | * the size is 1. |
| 449 | * |
| 450 | * JSMN supports a non-standard syntax such as |
| 451 | * `"key": 1 2 3 4`, which it considers as a |
| 452 | * string object that contains a sequence of |
| 453 | * sub-datums 1 2 3 4. |
| 454 | * The check below that p->size == 1 also |
| 455 | * incidentally rejects that non-standard |
| 456 | * JSON. |
| 457 | */ |
| 458 | if (p->type != JSMN_STRING || p->size != 1 |
| 459 | || !utf8_check(buf + p->start, p->end - p->start)) { |
| 460 | *valid = false; |
| 461 | return p; |
| 462 | } |
| 463 | |
| 464 | ++p; |
| 465 | return validate_jsmn_datum(buf, p, end, valid); |
| 466 | } |
| 467 | |
| 468 | /** validate_jsmn_parse_output |
| 469 | * |
no test coverage detected