summaryrefslogtreecommitdiff
path: root/src/blocks.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-06-16 22:21:55 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-06-16 22:22:56 -0700
commit04726a7089e44e7ff4e6c552524841579a1053da (patch)
treebc1657e17edb1d264a0cfe8adfe3c378b7baa8ae /src/blocks.c
parentfb7af2f0d6ca845b33364c6ce9a704a458e31ff9 (diff)
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.
Diffstat (limited to 'src/blocks.c')
-rw-r--r--src/blocks.c6
1 files changed, 5 insertions, 1 deletions
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;