this code is not check escape sequence.
whenever find backslash, escape_char function skipped 2byte.
If you input UTF-8 text with korean or chinese, code will be down.
I think escape_char must check defined escape sequence.
i fixed this issues.
check it my forked code.
/
orignal code isn't consider UNICODE or general charactor after backslash.
so I append to check logic for defined escape sequence.
by DongHyunKo
/
static size_t
char_escape(struct buf ob, struct render rndr,
char *data, size_t offset, size_t size) {
struct buf work = { 0, 0, 0, 0, 0 };
if( data[1] == 'b' || data[1] == 'b'
|| data[1] == 'f' || data[1] == 'n'
|| data[1] == 'r' || data[1] == 't'
|| data[1] == 'v' || data[1] == '\'
|| data[1] == '\'' || data[1] == '\"'
|| data[1] == '?' ) {
if (size > 1) {
if (rndr->make.normal_text) {
work.data = data + 1;
work.size = 1;
rndr->make.normal_text(ob, &work, rndr->make.opaque); }
else bufputc(ob, data[1]); }
return 2; }
return 0; }
this code is not check escape sequence. whenever find backslash, escape_char function skipped 2byte. If you input UTF-8 text with korean or chinese, code will be down.
I think escape_char must check defined escape sequence. i fixed this issues. check it my forked code.
/ orignal code isn't consider UNICODE or general charactor after backslash. so I append to check logic for defined escape sequence.
by DongHyunKo / static size_t char_escape(struct buf ob, struct render rndr, char *data, size_t offset, size_t size) { struct buf work = { 0, 0, 0, 0, 0 }; if( data[1] == 'b' || data[1] == 'b' || data[1] == 'f' || data[1] == 'n' || data[1] == 'r' || data[1] == 't' || data[1] == 'v' || data[1] == '\' || data[1] == '\'' || data[1] == '\"' || data[1] == '?' ) { if (size > 1) { if (rndr->make.normal_text) { work.data = data + 1; work.size = 1; rndr->make.normal_text(ob, &work, rndr->make.opaque); } else bufputc(ob, data[1]); } return 2; } return 0; }