diff --git a/src/xml.c b/src/xml.c index 881385a28..da70ab477 100644 --- a/src/xml.c +++ b/src/xml.c @@ -465,7 +465,7 @@ lyxml_parse_value(struct lyxml_ctx *xmlctx, char endchar, char **value, uint32_t uint32_t offset; /* read offset in input buffer */ uint32_t len; /* length of the output string (write offset in output buffer) */ uint32_t size = 0; /* size of the output buffer */ - uint32_t n, u; + uint32_t n, u, c, parsed; ly_bool ws = 1; assert(xmlctx); @@ -564,8 +564,10 @@ lyxml_parse_value(struct lyxml_ctx *xmlctx, char endchar, char **value, uint32_t in += ly_strlen_const("in); } else if (!is_xmlws(in[n])) { diff --git a/tests/utests/basic/test_xml.c b/tests/utests/basic/test_xml.c index 5712f3468..7fdf6ceb8 100644 --- a/tests/utests/basic/test_xml.c +++ b/tests/utests/basic/test_xml.c @@ -240,6 +240,25 @@ test_text(void **state) lyd_free_all(tree); tree = NULL; + str = ""; + assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, str, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree)); + assert_non_null(tree); + lyd_free_all(tree); + tree = NULL; + + /* CDATA characters are checked the same as text */ + str = ""; + assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, str, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree)); + CHECK_LOG_CTX("Invalid character 0x1.", NULL, 1); + + str = ""; + assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, str, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree)); + CHECK_LOG_CTX("Invalid character 0xff.", NULL, 1); + + str = ""; + assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, str, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree)); + CHECK_LOG_CTX("Invalid character 0xf0.", NULL, 1); + /* invalid characters in string */ str = "