Skip to content

Commit

Permalink
Fixes #1359: Prevent passing as CLI argument causing a useless subscr…
Browse files Browse the repository at this point in the history
…iption.

  Also checks for duplicates when subscribing from CLI/DBUS.
  • Loading branch information
lwindolf committed Jun 29, 2024
1 parent 4793bb4 commit db561b2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
To be released

Version 1.15.8

* Fixes #1359: Prevent passing "" as CLI argument causing a useless subscription.
Also checks for duplicates when subscribing from CLI/DBUS.
(Lars Windolf)


2024-06-19 Lars Windolf <[email protected]>

Version 1.15.7
Expand Down
24 changes: 16 additions & 8 deletions src/liferea_application.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file main.c Liferea startup
*
* Copyright (C) 2003-2023 Lars Windolf <[email protected]>
* Copyright (C) 2003-2024 Lars Windolf <[email protected]>
* Copyright (C) 2004-2006 Nathan J. Conrad <[email protected]>
*
* Some code like the command line handling was inspired by
Expand Down Expand Up @@ -89,15 +89,23 @@ on_app_open (GApplication *application,

for (i=0;(i<n_files) && uris[i];i++) {
gchar *uri = g_file_get_uri (uris[i]);
gchar *dir = g_get_current_dir ();

/* When passed to GFile feeds using the feed scheme "feed:https://" become "feed:///https:/" */
if (g_str_has_prefix (uri, "feed:///https:/")) {
gchar *tmp = uri;
uri = g_strdup_printf ("https://%s", uri + strlen ("feed:///https:/"));
g_free (tmp);
/* Prevent empty argument causing a subscription (Github #1359) */
if (!(g_str_has_prefix (uri, "file://") && g_str_equal (dir, uri + 7))) {

/* When passed to GFile feeds using the feed scheme "feed:https://" become "feed:///https:/" */
if (g_str_has_prefix (uri, "feed:///https:/")) {
gchar *tmp = uri;
uri = g_strdup_printf ("https://%s", uri + strlen ("feed:///https:/"));
g_free (tmp);
}

feedlist_add_subscription_check_duplicate (uri, NULL, NULL, 0);
g_free (uri);
}
feedlist_add_subscription (uri, NULL, NULL, 0);
g_free (uri);

g_free (dir);
}
}

Expand Down

0 comments on commit db561b2

Please sign in to comment.