From ca217fbef0d064565dc1bf114b837e2b59276f7d Mon Sep 17 00:00:00 2001 From: Patrick Storz Date: Sun, 20 Oct 2019 01:13:33 +0200 Subject: 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. --- src/extension/extension.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/extension/extension.cpp') 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 { -- cgit v1.2.3