| 1784 | } |
| 1785 | |
| 1786 | static int jl_validate_key(const char *key) { |
| 1787 | if (!key) { |
| 1788 | return -1; |
| 1789 | } |
| 1790 | size_t length = strlen(key); |
| 1791 | if (length > JL_MAX_KEY_BYTES) { |
| 1792 | return -1; |
| 1793 | } |
| 1794 | size_t pos = 0; |
| 1795 | while (pos < length) { |
| 1796 | uint32_t codepoint = 0; |
| 1797 | size_t byte_count = 0; |
| 1798 | if (jl_decode_utf8((const unsigned char *)key + pos, length - pos, &codepoint, |
| 1799 | &byte_count) != 0 || |
| 1800 | codepoint < 0x20U || (codepoint >= 0x7FU && codepoint <= 0x9FU)) { |
| 1801 | return -1; |
| 1802 | } |
| 1803 | pos += byte_count; |
| 1804 | } |
| 1805 | return 0; |
| 1806 | } |
| 1807 | |
| 1808 | static int jl_validate_string_value(const char *value) { |
| 1809 | if (!value) { |
no test coverage detected