]> wimlib.net Git - wimlib/commitdiff
xml: fix wimlib_set_image_property()
authorEric Biggers <ebiggers3@gmail.com>
Thu, 30 Mar 2023 08:16:52 +0000 (01:16 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Thu, 30 Mar 2023 08:16:52 +0000 (01:16 -0700)
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.

include/wimlib/xmlproc.h
src/xml.c
src/xmlproc.c

index c82ce57f3a2877eb9d0d8c8396c2eba5e9737026..c202d629765efaa51246b22115677a318f7156ed 100644 (file)
@@ -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);
index 63c3b4fb03e444a36386218e6671ff79ec723556..691a2373fe5b7824b5fb625f9eac39a23a83d30a 100644 (file)
--- 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;
        }
index 48569ff87f9fbc7461c63762596bc90d7236a8a3..b0045aec04aa003b4d2b1cdfd9a4b8e9d9d9bb5e 100644 (file)
@@ -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;