| 1851 | } |
| 1852 | |
| 1853 | static int jl_validate_key(const char *key) { |
| 1854 | if (!key) { |
| 1855 | return -1; |
| 1856 | } |
| 1857 | size_t length = strlen(key); |
| 1858 | if (length > JL_MAX_KEY_BYTES) { |
| 1859 | return -1; |
| 1860 | } |
| 1861 | size_t pos = 0; |
| 1862 | while (pos < length) { |
| 1863 | uint32_t codepoint = 0; |
| 1864 | size_t byte_count = 0; |
| 1865 | if (jl_decode_utf8((const unsigned char *)key + pos, length - pos, &codepoint, |
| 1866 | &byte_count) != 0 || |
| 1867 | codepoint < 0x20U || (codepoint >= 0x7FU && codepoint <= 0x9FU)) { |
| 1868 | return -1; |
| 1869 | } |
| 1870 | pos += byte_count; |
| 1871 | } |
| 1872 | return 0; |
| 1873 | } |
| 1874 | |
| 1875 | static int jl_validate_string_value(const char *value) { |
| 1876 | if (!value) { |
no test coverage detected