diff options
| author | Thomas Holder <thomas@thomas-holder.de> | 2019-11-03 17:25:54 +0000 |
|---|---|---|
| committer | Thomas Holder <thomas@thomas-holder.de> | 2019-11-03 17:38:41 +0000 |
| commit | 0cb85e3840d3f11f1b920324ef0fac695bbdf01e (patch) | |
| tree | 9c55ece9716a3abf975401f0710033d51c9c45c9 /src | |
| parent | Remove tests LPE to be woking apart in this branch: (diff) | |
| download | inkscape-0cb85e3840d3f11f1b920324ef0fac695bbdf01e.tar.gz inkscape-0cb85e3840d3f11f1b920324ef0fac695bbdf01e.zip | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/xml/simple-node.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
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 <algorithm> #include <cstring> #include <string> @@ -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); |
