From 734bf0a11abd23825999468a2d26c6f41794943a Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 14 Dec 2024 12:47:59 +0100 Subject: [PATCH 1/4] Remove restrictive validation --- ChangeLog | 10 ++++++++++ src/main.c | 11 ++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index be38de3..dcb32cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2024-12-14 Serghei Iakovlev + + * src/main.c (main): Removed restrictive validation on input URLs. + Now allows any non-empty argument, including local files and custom + schemes, ensuring the program functions as a transparent router. + Added minimal check for empty string input. + + * src/main.c (main): Removed unnecessary debug statements + printing the number of loaded rules and the selected command. + 2024-12-13 Serghei Iakovlev * configure.ac: Removed debug-mode and werror logic, as well as diff --git a/src/main.c b/src/main.c index 2149934..6382485 100644 --- a/src/main.c +++ b/src/main.c @@ -33,14 +33,15 @@ int main(int argc, char *argv[]) { return 1; } - const char *url = argv[1]; - if (strncmp(url, "http://", 7) != 0 && strncmp(url, "https://", 8) != 0) { - fprintf(stderr, "Invalid URL. Must start with http:// or https://\n"); + if (argv[1][0] == '\0') { + fprintf(stderr, "Error: Empty URL or file path provided\n"); return 1; } + const char *url = argv[1]; Rule *rules = NULL; size_t rule_count = 0; + if (config_load_rules(&rules, &rule_count) != 0) { fprintf(stderr, "Error loading configuration\n"); return 1; @@ -49,10 +50,6 @@ int main(int argc, char *argv[]) { const char *default_browser = "firefox"; const char *command = matcher_find_command(url, rules, rule_count, default_browser); - // For now, just print how many rules we have loaded - printf("Loaded %zu rules.\n", rule_count); - printf("Command to execute: %s\n", command); - int ret = executor_run_command(command, url); if (ret != 0) { fprintf(stderr, "Failed to execute command: %s\n", command); From 7e6e624be18e67c0029ebe008dd9fdfa0eb98668 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 14 Dec 2024 12:51:54 +0100 Subject: [PATCH 2/4] Corrected typo in copyright notice --- ChangeLog | 3 +++ src/brogw_config.c | 2 +- src/brogw_config.h | 2 +- src/executor.c | 2 +- src/executor.h | 2 +- src/main.c | 2 +- src/matcher.c | 2 +- src/matcher.h | 2 +- src/utils.c | 2 +- src/utils.h | 2 +- 10 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index dcb32cf..6dbd8d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,9 @@ * src/main.c (main): Removed unnecessary debug statements printing the number of loaded rules and the selected command. + * src/*.c, src/*.h: Corrected typo in copyright notice ('Brigw' -> + 'Brogw'). + 2024-12-13 Serghei Iakovlev * configure.ac: Removed debug-mode and werror logic, as well as diff --git a/src/brogw_config.c b/src/brogw_config.c index 7a313fa..48b17b9 100644 --- a/src/brogw_config.c +++ b/src/brogw_config.c @@ -14,7 +14,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Brigw. If not, see . */ +along with Brogw. If not, see . */ #include diff --git a/src/brogw_config.h b/src/brogw_config.h index 14318c3..263ab00 100644 --- a/src/brogw_config.h +++ b/src/brogw_config.h @@ -14,7 +14,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Brigw. If not, see . */ +along with Brogw. If not, see . */ #ifndef BROGW_BROGW_CONFIG_H diff --git a/src/executor.c b/src/executor.c index 1439085..a1ec7ef 100644 --- a/src/executor.c +++ b/src/executor.c @@ -14,7 +14,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Brigw. If not, see . */ +along with Brogw. If not, see . */ #include diff --git a/src/executor.h b/src/executor.h index 5563a30..10f199e 100644 --- a/src/executor.h +++ b/src/executor.h @@ -14,7 +14,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Brigw. If not, see . */ +along with Brogw. If not, see . */ #ifndef BROGW_EXECUTOR_H diff --git a/src/main.c b/src/main.c index 6382485..0c40775 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Brigw. If not, see . */ +along with Brogw. If not, see . */ #include diff --git a/src/matcher.c b/src/matcher.c index 97152ac..e0d90a9 100644 --- a/src/matcher.c +++ b/src/matcher.c @@ -14,7 +14,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Brigw. If not, see . */ +along with Brogw. If not, see . */ #include #include diff --git a/src/matcher.h b/src/matcher.h index 0a0338a..e28f739 100644 --- a/src/matcher.h +++ b/src/matcher.h @@ -14,7 +14,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Brigw. If not, see . */ +along with Brogw. If not, see . */ #ifndef BROGW_MATCHER_H diff --git a/src/utils.c b/src/utils.c index 3177e15..a234e0a 100644 --- a/src/utils.c +++ b/src/utils.c @@ -14,7 +14,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Brigw. If not, see . */ +along with Brogw. If not, see . */ #include diff --git a/src/utils.h b/src/utils.h index 7a4cd9a..3f13042 100644 --- a/src/utils.h +++ b/src/utils.h @@ -14,7 +14,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Brigw. If not, see . */ +along with Brogw. If not, see . */ #ifndef BROGW_UTILS_H From 304e17db380509e3e432aebf5ba42e2f136f713e Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 14 Dec 2024 20:07:40 +0100 Subject: [PATCH 3/4] Update NEWS file --- NEWS | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/NEWS b/NEWS index aad9959..4bcfd48 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,18 @@ tested across these platforms. This is intended for future flexibility in feature toggles and platform-specific conditions. +** Routing to any input. +Brogw now supports routing of any non-empty input, including local +file paths (e.g., '~/file.html') and custom schemes (e.g., `file://`, +`ftp://`). Removed the restrictive check requiring input to start +with 'http://' or 'https://'. + +** Improved error handling. +Added validation to reject empty string inputs, e.g., 'brogw ""'. + +** Code cleanup. +Cleaned up runtime output by removing unnecessary debug logs. + * Release 1.0, 2024-12-10 Initial release. From 5bfb4a7623a0ca85b6fc495def1bd7100703dee6 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 14 Dec 2024 20:16:37 +0100 Subject: [PATCH 4/4] Improve integration with desktop environments --- ChangeLog | 8 ++++++-- NEWS | 6 ++++++ etc/brogw.desktop | 7 +++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6dbd8d1..67228db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,8 +8,12 @@ * src/main.c (main): Removed unnecessary debug statements printing the number of loaded rules and the selected command. - * src/*.c, src/*.h: Corrected typo in copyright notice ('Brigw' -> - 'Brogw'). + * src/*.c, src/*.h: Corrected typo in copyright notice. + + * etc/brogw.desktop: Updated to conform with the Desktop Entry + specification. Added 'Version', 'GenericName', and + 'StartupNotify' fields. Specified `Terminal=false` for graphical + environments. 2024-12-13 Serghei Iakovlev diff --git a/NEWS b/NEWS index 4bcfd48..90dd72d 100644 --- a/NEWS +++ b/NEWS @@ -36,6 +36,12 @@ Added validation to reject empty string inputs, e.g., 'brogw ""'. ** Code cleanup. Cleaned up runtime output by removing unnecessary debug logs. +** Improved integration with desktop environments. +Updated the '.desktop' file to conform with the Freedesktop Desktop +Entry specification. Added 'Version', 'GenericName', 'Terminal' and +'StartupNofify' fields to ensure proper behavior in graphical +environments. + * Release 1.0, 2024-12-10 Initial release. diff --git a/etc/brogw.desktop b/etc/brogw.desktop index 054f516..427b485 100644 --- a/etc/brogw.desktop +++ b/etc/brogw.desktop @@ -1,7 +1,14 @@ +# For information about the Desktop Entry specification, +# see http://freedesktop.org/wiki/Specifications/desktop-entry-spec. + [Desktop Entry] +Version=1.0 Name=Brogw +GenericName=Web Browser Comment=Route links to appropriate web browser Type=Application Exec=brogw %u +Terminal=false Categories=Network;WebBrowser +StartupNotify=false MimeType=x-scheme-handler/http;x-scheme-handler/https;