data parser CHANGE remove trusted flag
It is not needed for LYB format at all
and generally should not really be used
because it poses a risk of considering
invalid data as validated.
diff --git a/src/parser_data.h b/src/parser_data.h
index ae6322f..02175d4 100644
--- a/src/parser_data.h
+++ b/src/parser_data.h
@@ -142,16 +142,13 @@
are kept unevaluated, union types may not be fully resolved, if-feature
statements are not checked, and default values are not added (only the ones
parsed are present). */
-#define LYD_PARSE_TRUSTED 0x020000 /**< Data are considered trusted so they will be parsed as validated. If the parsed
- data are not valid, using this flag may lead to some unexpected behavior!
- This flag can be used only with #LYD_PARSE_ONLY. */
-#define LYD_PARSE_STRICT 0x040000 /**< Instead of silently ignoring data without schema definition raise an error.
+#define LYD_PARSE_STRICT 0x020000 /**< Instead of silently ignoring data without schema definition raise an error.
Do not combine with #LYD_PARSE_OPAQ (except for ::LYD_LYB). */
-#define LYD_PARSE_OPAQ 0x080000 /**< Instead of silently ignoring data without definition, parse them into
+#define LYD_PARSE_OPAQ 0x040000 /**< Instead of silently ignoring data without definition, parse them into
an opaq node. Do not combine with #LYD_PARSE_STRICT (except for ::LYD_LYB). */
-#define LYD_PARSE_NO_STATE 0x100000 /**< Forbid state data in the parsed data. */
+#define LYD_PARSE_NO_STATE 0x080000 /**< Forbid state data in the parsed data. */
-#define LYD_PARSE_LYB_MOD_UPDATE 0x200000 /**< Only for LYB format, allow parsing data printed using a specific module
+#define LYD_PARSE_LYB_MOD_UPDATE 0x100000 /**< Only for LYB format, allow parsing data printed using a specific module
revision to be loaded even with a module with the same name but newer
revision. */
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index 79550d6..6979586 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -240,20 +240,12 @@
struct lyd_meta *meta2, *prev_meta = NULL;
if (!(node->schema->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)) && node->schema->when) {
- if (options & LYD_PARSE_TRUSTED) {
- /* just set it to true */
- node->flags |= LYD_WHEN_TRUE;
- } else if (!(options & LYD_PARSE_ONLY)) {
+ if (!(options & LYD_PARSE_ONLY)) {
/* remember we need to evaluate this node's when */
LY_CHECK_RET(ly_set_add(when_check, node, 1, NULL), );
}
}
- if (options & LYD_PARSE_TRUSTED) {
- /* node is valid */
- node->flags &= ~LYD_NEW;
- }
-
LY_LIST_FOR(*meta, meta2) {
if (!strcmp(meta2->name, "default") && !strcmp(meta2->annotation->module->name, "ietf-netconf-with-defaults") &&
meta2->value.boolean) {
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index 2bfedba..9a33ad2 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -1323,7 +1323,7 @@
"<lf1>not true</lf1>"
"</cont>"
"<lf3 xmlns=\"urn:tests:j\">target</lf3>";
- assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_TRUSTED, 0, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY, 0, &tree));
assert_non_null(tree);
/* input must false */
@@ -1336,7 +1336,7 @@
"<lf1>true</lf1>"
"</cont>"
"<lf3 xmlns=\"urn:tests:j\">target</lf3>";
- assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_TRUSTED, 0, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY, 0, &tree));
assert_non_null(tree);
/* success */
@@ -1388,7 +1388,7 @@
"<lf1>not true</lf1>"
"</cont>"
"<lf4 xmlns=\"urn:tests:j\">target</lf4>";
- assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_TRUSTED, 0, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY, 0, &tree));
assert_non_null(tree);
/* input must false */
@@ -1401,7 +1401,7 @@
"<lf1>true2</lf1>"
"</cont>"
"<lf4 xmlns=\"urn:tests:j\">target</lf4>";
- assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_TRUSTED, 0, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY, 0, &tree));
assert_non_null(tree);
/* success */