From: Eric Biggers Date: Thu, 30 Mar 2023 08:16:52 +0000 (-0700) Subject: xml: fix wimlib_set_image_property() X-Git-Tag: v1.14.0~39 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=36d2328da0a9502bd87613621e49a9dcf8fa485f xml: fix wimlib_set_image_property() The recent XML changes introduced a bug where wimlib_set_image_property() rejected values of property_name containing '/', '[', or ']', which are part of the "path" syntax. --- diff --git a/include/wimlib/xmlproc.h b/include/wimlib/xmlproc.h index c82ce57f..c202d629 100644 --- a/include/wimlib/xmlproc.h +++ b/include/wimlib/xmlproc.h @@ -66,7 +66,7 @@ struct xml_node * xml_clone_tree(struct xml_node *orig); bool -xml_legal_name(const tchar *name); +xml_legal_path(const tchar *name); bool xml_legal_value(const tchar *value); diff --git a/src/xml.c b/src/xml.c index 63c3b4fb..691a2373 100644 --- a/src/xml.c +++ b/src/xml.c @@ -1213,7 +1213,7 @@ wimlib_set_image_property(WIMStruct *wim, int image, const tchar *property_name, if (!property_name || !*property_name) return WIMLIB_ERR_INVALID_PARAM; - if (!xml_legal_name(property_name)) { + if (!xml_legal_path(property_name)) { ERROR("Property name '%"TS"' is illegal in XML", property_name); return WIMLIB_ERR_INVALID_PARAM; } diff --git a/src/xmlproc.c b/src/xmlproc.c index 48569ff8..b0045aec 100644 --- a/src/xmlproc.c +++ b/src/xmlproc.c @@ -318,13 +318,20 @@ is_name_char(tchar c) (c >= '0' && c <= '9') || c == '-' || c == '.'; } +/* Allow characters used in element "paths"; see do_xml_path_walk() */ +static inline bool +is_path_char(tchar c) +{ + return c == '/' || c == '[' || c == ']'; +} + bool -xml_legal_name(const tchar *p) +xml_legal_path(const tchar *p) { - if (!is_name_start_char(*p)) + if (!is_name_start_char(*p) && !is_path_char(*p)) return false; for (p = p + 1; *p; p++) { - if (!is_name_char(*p)) + if (!is_name_char(*p) && !is_path_char(*p)) return false; } return true;