[geany/geany] cc18dd: Gracefully handle proxies registering invalid extensions (#1212)

Matthew Brush git-noreply at xxxxx
Sun Sep 11 02:24:16 UTC 2016


Branch:      refs/heads/master
Author:      Matthew Brush <mbrush at codebrainz.ca>
Committer:   GitHub <noreply at github.com>
Date:        Sun, 11 Sep 2016 02:24:16 UTC
Commit:      cc18dd0e60938141bc702ed3da3218e1144de2a4
             https://github.com/geany/geany/commit/cc18dd0e60938141bc702ed3da3218e1144de2a4

Log Message:
-----------
Gracefully handle proxies registering invalid extensions (#1212)

It is very hard to debug if the proxy plugin happens to give
extensions starting with a dot. If they do, detect this case, warn
in the debug messages, and fix the extension. It seems unlikely
that files with two dot extensions will be desired, so it should
case no harm.


Modified Paths:
--------------
    src/plugins.c

Modified: src/plugins.c
14 lines changed, 13 insertions(+), 1 deletions(-)
===================================================================
@@ -1966,6 +1966,18 @@ static void pm_show_dialog(GtkMenuItem *menuitem, gpointer user_data)
 }
 
 
+static const gchar *fix_extension(const gchar *ext)
+{
+	if (*ext == '.')
+	{
+		g_warning(_("Proxy plugin extension '%s' starts with a dot, "
+			"stripping. Please fix your proxy plugin."), ext);
+		ext++;
+	}
+	return ext;
+}
+
+
 /** Register the plugin as a proxy for other plugins
  *
  * Proxy plugins register a list of file extensions and a set of callbacks that are called
@@ -2017,7 +2029,7 @@ gboolean geany_plugin_register_proxy(GeanyPlugin *plugin, const gchar **extensio
 	foreach_strv(ext, extensions)
 	{
 		proxy = g_new(PluginProxy, 1);
-		g_strlcpy(proxy->extension, *ext, sizeof(proxy->extension));
+		g_strlcpy(proxy->extension, fix_extension(*ext), sizeof(proxy->extension));
 		proxy->plugin = p;
 		/* prepend, so that plugins automatically override core providers for a given extension */
 		g_queue_push_head(&active_proxies, proxy);



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list