summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-10-19 23:13:33 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-10-19 23:13:33 +0000
commitca217fbef0d064565dc1bf114b837e2b59276f7d (patch)
tree839b29c43eb9121573538b497188707086a56c7d /src
parentMore improvements to the objects panel: (diff)
downloadinkscape-ca217fbef0d064565dc1bf114b837e2b59276f7d.tar.gz
inkscape-ca217fbef0d064565dc1bf114b837e2b59276f7d.zip
Extensions: catch parameters and translatable values with empty name
A parameter with empty name (or name consisting of whitespace only) can cause undefined behavior and should be avoided at all cost. Empty translatable values like "gui-text"/"gui-description", while not encouraged, might be acceptable. However they must not be translated as gettext would return the full metadata of the .po file in this case.
Diffstat (limited to 'src')
-rw-r--r--src/extension/extension.cpp5
-rw-r--r--src/extension/prefdialog/parameter.cpp6
2 files changed, 9 insertions, 2 deletions
diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp
index 9089dc950..96652c272 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -540,6 +540,11 @@ const char *Extension::get_translation(const char *msgid, const char *msgctxt) {
return msgid;
}
+ if (!strcmp(msgid, "")) {
+ g_warning("Attempting to translate an empty string in extension '%s', which is not supported.", _id);
+ return msgid;
+ }
+
if (msgctxt) {
return g_dpgettext2(_translationdomain, msgctxt, msgid);
} else {
diff --git a/src/extension/prefdialog/parameter.cpp b/src/extension/prefdialog/parameter.cpp
index 8cee78f43..14ccfc394 100644
--- a/src/extension/prefdialog/parameter.cpp
+++ b/src/extension/prefdialog/parameter.cpp
@@ -226,11 +226,13 @@ InxParameter::InxParameter(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex
{
// name (mandatory for all parameters)
const char *name = in_repr->attribute("name");
- if (!name) {
+ if (name) {
+ _name = g_strstrip(g_strdup(name));
+ }
+ if (!_name || !strcmp(_name, "")) {
g_warning("Parameter without name in extension '%s'.", _extension->get_id());
throw param_no_name();
}
- _name = g_strdup(name);
// gui-text
const char *gui_text = in_repr->attribute("gui-text");