| 1786 | |
| 1787 | |
| 1788 | int json_unescape(CHARSET_INFO *json_cs, |
| 1789 | const uchar *json_str, const uchar *json_end, |
| 1790 | CHARSET_INFO *res_cs, uchar *res, uchar *res_end) |
| 1791 | { |
| 1792 | json_string_t s; |
| 1793 | const uchar *res_b= res; |
| 1794 | |
| 1795 | json_string_setup(&s, json_cs, json_str, json_end); |
| 1796 | while (json_read_string_const_chr(&s) == 0) |
| 1797 | { |
| 1798 | int c_len; |
| 1799 | if ((c_len= my_ci_wc_mb(res_cs, s.c_next, res, res_end)) > 0) |
| 1800 | { |
| 1801 | res+= c_len; |
| 1802 | continue; |
| 1803 | } |
| 1804 | if (c_len == MY_CS_ILUNI) |
| 1805 | { |
| 1806 | return JSON_ERROR_ILLEGAL_SYMBOL; |
| 1807 | } |
| 1808 | /* Result buffer is too small. */ |
| 1809 | return JSON_ERROR_OUT_OF_SPACE; |
| 1810 | } |
| 1811 | |
| 1812 | return s.error==JE_EOS ? (int)(res - res_b) : JSON_ERROR_OUT_OF_SPACE; |
| 1813 | } |
| 1814 | |
| 1815 | |
| 1816 | /* When we need to replace a character with the escaping. */ |
no test coverage detected