From 0cb85e3840d3f11f1b920324ef0fac695bbdf01e Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Sun, 3 Nov 2019 18:25:54 +0100 Subject: sanity check for XML attribute names - addresses inbox#1007 (no solid fix, but should catch typical mistakes) - would have prevented inbox#976 - would have prevented https://gitlab.com/inkscape/inkscape/commit/54f45153ba#note_239314490 --- src/xml/simple-node.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/xml') diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp index 47f66ff85..fc74cfaec 100644 --- a/src/xml/simple-node.cpp +++ b/src/xml/simple-node.cpp @@ -13,6 +13,7 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ +#include #include #include @@ -321,6 +322,9 @@ SimpleNode::setAttribute(gchar const *name, gchar const *value, bool const /*is_ { g_return_if_fail(name && *name); + // sanity check: `name` must not contain whitespace + g_assert(std::none_of(name, name + strlen(name), [](char c) { return g_ascii_isspace(c); })); + // Check usefulness of attributes on elements in the svg namespace, optionally don't add them to tree. Glib::ustring element = g_quark_to_string(_name); //g_message("setAttribute: %s: %s: %s", element.c_str(), name, value); -- cgit v1.2.3