From 04726a7089e44e7ff4e6c552524841579a1053da Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 16 Jun 2015 22:21:55 -0700 Subject: Added `CMARK_OPT_VALIDATE_UTF8` option. Also command line option `--validate-utf8`. This option causes cmark to check for valid UTF-8, replacing invalid sequences with the replacement character, U+FFFD. Reinstated api tests for utf8. --- src/blocks.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/blocks.c') diff --git a/src/blocks.c b/src/blocks.c index 95a87c3..17288df 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -631,7 +631,11 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, bufsize_t byte cmark_chunk input; bool maybe_lazy; - cmark_strbuf_put(parser->curline, buffer, bytes); + if (parser->options & CMARK_OPT_VALIDATE_UTF8) { + utf8proc_check(parser->curline, buffer, bytes); + } else { + cmark_strbuf_put(parser->curline, buffer, bytes); + } parser->offset = 0; parser->column = 0; parser->blank = false; -- cgit v1.2.3