Skip to content

Commit

Permalink
parser BUGFIX do not print opaque node parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvasko committed Oct 21, 2024
1 parent e853b19 commit 8a8fde0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/parser_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ lydjson_data_check_opaq(struct lyd_json_ctx *lydctx, const struct lysc_node *sno
LY_ERR ret = LY_SUCCESS;
struct lyjson_ctx *jsonctx = lydctx->jsonctx;
enum LYJSON_PARSER_STATUS status;
uint32_t *prev_lo, temp_lo = 0;

assert(snode);

Expand All @@ -523,9 +524,12 @@ lydjson_data_check_opaq(struct lyd_json_ctx *lydctx, const struct lysc_node *sno
if ((ret = lydjson_value_type_hint(jsonctx, &status, type_hint_p))) {
break;
}

prev_lo = ly_temp_log_options(&temp_lo);
if (ly_value_validate(NULL, snode, jsonctx->value, jsonctx->value_len, LY_VALUE_JSON, NULL, *type_hint_p)) {
ret = LY_ENOT;
}
ly_temp_log_options(prev_lo);
break;
case LYS_LIST:
/* lists may not have all its keys */
Expand Down
8 changes: 6 additions & 2 deletions src/parser_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,9 @@ lydxml_data_skip(struct lyxml_ctx *xmlctx)
static LY_ERR
lydxml_data_check_opaq(struct lyd_xml_ctx *lydctx, const struct lysc_node **snode)
{
LY_ERR ret = LY_SUCCESS;
LY_ERR ret = LY_SUCCESS, r;
struct lyxml_ctx *xmlctx = lydctx->xmlctx, pxmlctx;
uint32_t *prev_lo, temp_lo = 0;

if (!(lydctx->parse_opts & LYD_PARSE_OPAQ)) {
/* only checks specific to opaque nodes */
Expand All @@ -420,7 +421,10 @@ lydxml_data_check_opaq(struct lyd_xml_ctx *lydctx, const struct lysc_node **snod

if ((*snode)->nodetype & LYD_NODE_TERM) {
/* value may not be valid in which case we parse it as an opaque node */
if (ly_value_validate(NULL, *snode, xmlctx->value, xmlctx->value_len, LY_VALUE_XML, &xmlctx->ns, LYD_HINT_DATA)) {
prev_lo = ly_temp_log_options(&temp_lo);
r = ly_value_validate(NULL, *snode, xmlctx->value, xmlctx->value_len, LY_VALUE_XML, &xmlctx->ns, LYD_HINT_DATA);
ly_temp_log_options(prev_lo);
if (r) {
LOGVRB("Parsing opaque term node \"%s\" with invalid value \"%.*s\".", (*snode)->name, (int)xmlctx->value_len,
xmlctx->value);
*snode = NULL;
Expand Down

0 comments on commit 8a8fde0

Please sign in to comment.