> @@ -1356,7 +1748,7 @@ static void on_pm_tree_filter_entry_icon_release_cb(GtkEntry *entry, GtkEntryIco
> }
>
>
> -static void pm_prepare_treeview(GtkWidget *tree, GtkListStore *store)
> +static void pm_prepare_treeview(GtkWidget *tree, GtkTreeStore *store)
changes to this function lead to `iter` and `list` variables to be unused.
---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/629/files#r41078619
> +@endcode
> +
> +Finally the demo_proxy's wrapper GeanyPluginFuncs. They are called for each possible sub-plugin and
> +therefore have to multiplex between each using the plugin-defined data pointer. Each is called by
> +Geany as if it were an ordinary, native plugin.
> +
> +proxy_init() actually reads the sub-plugin's file using GKeyFile APIs. It prepares for the help
> +dialog and installs the menu items. proxy_help() is called when the user clicks the help button in
> +the Plugin Manager. Consequently, this fires up a suitable dialog, although with a dummy message.
> +proxy_cleanup() frees all memory allocated in proxy_init().
> +
> +(a)code{.c}
> +static gboolean proxy_init(GeanyPlugin *plugin, gpointer pdata)
> +{
> + PluginContext *data;
> + gchar fmt[] = "item%d";
here too for the format thing
---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/629/files#r41078149
> @@ -830,25 +1011,80 @@ static gboolean check_plugin_path(const gchar *fname)
> }
>
>
> +/* Retuns NULL if this ain't a plugin,
> + * otherwise it returns the appropriate PluginProxy instance to load it */
> +static PluginProxy* is_plugin(const gchar *file)
> +{
> + GList *node;
> + const gchar *ext;
> +
> + /* extract file extension to avoid g_str_has_suffix() in the loop */
> + ext = (const gchar *)strrchr(file, '.');
> + if (ext == NULL)
> + return FALSE;
> + /* ensure the dot is really part of the filename */
> + else if (strchr(ext, G_DIR_SEPARATOR) != NULL)
> + return FALSE;
Doesn't seem to be true if I can read it (quickly) correctly: `load_active_plugins()` read `active_plugins_pref` directly, which was loaded from the config file. There the path is obviously absolute (and it's the case in my local Geany's config), as it's checked for existence.
So AFAICT I could at least force a `\` in the path by manually editing the config file.
---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/629/files#r41072107
> @@ -830,25 +1011,80 @@ static gboolean check_plugin_path(const gchar *fname)
> }
>
>
> +/* Retuns NULL if this ain't a plugin,
> + * otherwise it returns the appropriate PluginProxy instance to load it */
> +static PluginProxy* is_plugin(const gchar *file)
> +{
> + GList *node;
> + const gchar *ext;
> +
> + /* extract file extension to avoid g_str_has_suffix() in the loop */
> + ext = (const gchar *)strrchr(file, '.');
> + if (ext == NULL)
> + return FALSE;
> + /* ensure the dot is really part of the filename */
> + else if (strchr(ext, G_DIR_SEPARATOR) != NULL)
> + return FALSE;
In this case it is guaranteed. geany.cfg stores only the plugin's basename, not the full path. The full path is always constructed using g_build_path() prior to calling plugin_new()
---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/629/files#r41071290
> @@ -830,25 +1011,80 @@ static gboolean check_plugin_path(const gchar *fname)
> }
>
>
> +/* Retuns NULL if this ain't a plugin,
> + * otherwise it returns the appropriate PluginProxy instance to load it */
> +static PluginProxy* is_plugin(const gchar *file)
> +{
> + GList *node;
> + const gchar *ext;
> +
> + /* extract file extension to avoid g_str_has_suffix() in the loop */
> + ext = (const gchar *)strrchr(file, '.');
> + if (ext == NULL)
> + return FALSE;
> + /* ensure the dot is really part of the filename */
> + else if (strchr(ext, G_DIR_SEPARATOR) != NULL)
> + return FALSE;
> BTW, this is always called with the result of g_build_filename() (either directly or via plugin->filename) so it's kind of guaranteed it's a canonical path.
Fair enough if it's the case. Can't this change in the prefs? (e.g. if I manually alter the config file of the enabled plugin list)
> Actually, I'm preferring to leave it. We can't have paranoid checks everywhere, even in the deepest leaf functions. At some point we can/have to/should depend on earlier code to provide canonical paths, as is the case here.
Well, sure, if it's something we can totally rely on. But that means we need to guarantee it -- and here it's not really a "deep function" in that it extract a very low level info (the extension) --, e.g. that we don't work on paths as the OS understands it, but on an internal representation.
---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/629/files#r41071009
> @@ -830,25 +1011,80 @@ static gboolean check_plugin_path(const gchar *fname)
> }
>
>
> +/* Retuns NULL if this ain't a plugin,
> + * otherwise it returns the appropriate PluginProxy instance to load it */
> +static PluginProxy* is_plugin(const gchar *file)
> +{
> + GList *node;
> + const gchar *ext;
> +
> + /* extract file extension to avoid g_str_has_suffix() in the loop */
> + ext = (const gchar *)strrchr(file, '.');
> + if (ext == NULL)
> + return FALSE;
> + /* ensure the dot is really part of the filename */
> + else if (strchr(ext, G_DIR_SEPARATOR) != NULL)
> + return FALSE;
Actually, I'm preferring to leave it. We can't have paranoid checks everywhere, even in the deepest leaf functions. At some point we can/have to/should depend on earlier code to provide canonical paths, as is the case here.
---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/629/files#r41070363
> @@ -830,25 +1011,80 @@ static gboolean check_plugin_path(const gchar *fname)
> }
>
>
> +/* Retuns NULL if this ain't a plugin,
> + * otherwise it returns the appropriate PluginProxy instance to load it */
> +static PluginProxy* is_plugin(const gchar *file)
> +{
> + GList *node;
> + const gchar *ext;
> +
> + /* extract file extension to avoid g_str_has_suffix() in the loop */
> + ext = (const gchar *)strrchr(file, '.');
> + if (ext == NULL)
> + return FALSE;
> + /* ensure the dot is really part of the filename */
> + else if (strchr(ext, G_DIR_SEPARATOR) != NULL)
> + return FALSE;
BTW, this is always called with the result of g_build_filename() (either directly or via plugin->filename) so it's kind of guaranteed it's a canonical path.
---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/629/files#r41069639
> @@ -830,25 +1011,80 @@ static gboolean check_plugin_path(const gchar *fname)
> }
>
>
> +/* Retuns NULL if this ain't a plugin,
> + * otherwise it returns the appropriate PluginProxy instance to load it */
> +static PluginProxy* is_plugin(const gchar *file)
> +{
> + GList *node;
> + const gchar *ext;
> +
> + /* extract file extension to avoid g_str_has_suffix() in the loop */
> + ext = (const gchar *)strrchr(file, '.');
> + if (ext == NULL)
> + return FALSE;
> + /* ensure the dot is really part of the filename */
> + else if (strchr(ext, G_DIR_SEPARATOR) != NULL)
> + return FALSE;
What can you suggest. Two ifs?
---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/629/files#r41069232