data types CHANGE validate instance-identifier values
Quite a big patch dut to the problems with instance-identifiers:
- different format in XML and JSON
- prefixes must be resolved correctly even in predicates to be able to
compare values in predicates with other values (even another
instance-identifier, prefixed identityrefs or, in contrast, strings
where 'something:' is not a prefix).
diff --git a/src/common.c b/src/common.c
index 76f3b84..3c36baa 100644
--- a/src/common.c
+++ b/src/common.c
@@ -425,9 +425,9 @@
}
LY_ERR
-ly_parse_instance_predicate(const char **pred, size_t limit,
- const char **prefix, size_t *prefix_len, const char **id, size_t *id_len, const char **value, size_t *value_len,
- const char **errmsg)
+ly_parse_instance_predicate(const char **pred, size_t limit, LYD_FORMAT format,
+ const char **prefix, size_t *prefix_len, const char **id, size_t *id_len, const char **value, size_t *value_len,
+ const char **errmsg)
{
LY_ERR ret = LY_EVALID;
const char *in = *pred;
@@ -473,6 +473,11 @@
*errmsg = "Invalid node-identifier.";
goto error;
}
+ if (format == LYD_XML && !(*prefix)) {
+ /* all node names MUST be qualified with explicit namespace prefix */
+ *errmsg = "Missing prefix of a node name.";
+ goto error;
+ }
offset = in - *pred;
in = *pred;
expr = 2;
@@ -500,7 +505,7 @@
goto error;
}
*value = &in[offset];
- for (;offset < limit && in[offset] != quot; offset++);
+ for (;offset < limit && (in[offset] != quot || (offset && in[offset - 1] == '\\')); offset++);
if (in[offset] == quot) {
*value_len = &in[offset] - *value;
offset++;