From 6880bf722d254d12e8236c78a7d858b9c94deee6 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 29 May 2020 23:44:13 +0200 Subject: uri.c: Add support for relative paths --- uri.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'uri.c') diff --git a/uri.c b/uri.c index 6843e4a..59e50d7 100644 --- a/uri.c +++ b/uri.c @@ -11,12 +11,29 @@ const gchar * badwolf_ensure_uri_scheme(const gchar *text, gboolean try_file) { const gchar *fallback = "about:blank"; + char *path = NULL; if(g_strcmp0(text, "") <= 0) return fallback; if(g_uri_parse_scheme(text)) return text; - if(try_file && (access(text, R_OK) == 0)) return g_strdup_printf("file://%s", text); + if(try_file) + { + path = realpath(text, NULL); + gchar *f = NULL; + + if(path != NULL) + { + if(access(path, R_OK) == 0) + { + f = g_strdup_printf("file://%s", path); + } + + free(path); + + return f; + } + } return g_strdup_printf("http://%s", text); } -- cgit v1.3.1-23-gd82d From ed40d74fdde65134365334b8d0d2b5593c121b89 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 29 May 2020 23:55:25 +0200 Subject: Fix implicit-declaration for realpath --- Makefile | 2 +- po/messages.pot | 4 ++-- uri.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'uri.c') diff --git a/Makefile b/Makefile index f371a28..9cd4d96 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ EXE_test = uri_test TRANS = fr.mo pt_BR.mo DOCS = usr.bin.badwolf README.md KnowledgeBase.md interface.txt -CDEPS = -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION_FULL)\" +CDEPS = -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION_FULL)\" CDEPS += `$(PKGCONFIG) --cflags $(DEPS)` LIBS = `$(PKGCONFIG) --libs $(DEPS)` diff --git a/po/messages.pot b/po/messages.pot index 8b30b0d..28609d4 100644 --- a/po/messages.pot +++ b/po/messages.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Badwolf 1.0.0+gfffd169.develop\n" +"Project-Id-Version: Badwolf 1.0.0+g6880bf7.develop\n" "Report-Msgid-Bugs-To: contact+badwolf-msgid@hacktivis.me\n" -"POT-Creation-Date: 2020-05-29 23:45+0200\n" +"POT-Creation-Date: 2020-05-29 23:52+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/uri.c b/uri.c index 59e50d7..912bf86 100644 --- a/uri.c +++ b/uri.c @@ -4,7 +4,8 @@ #include "uri.h" -#include /* g_strcmp0() */ +#include /* g_strcmp0(), g_uri_parse_scheme(), g_strdup_printf */ +#include /* realpath(), free() */ #include /* access() */ const gchar * -- cgit v1.3.1-23-gd82d From 46ce59c9d63a8ab20117b5eb85afb52c0d6390a1 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 9 Apr 2021 07:44:41 +0200 Subject: Update copyright year --- COPYING | 2 +- README.md | 2 +- badwolf.c | 2 +- keybindings.c | 4 ++-- uri.c | 2 +- uri_test.c | 2 +- usr.bin.badwolf | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) (limited to 'uri.c') diff --git a/COPYING b/COPYING index 6ba3f5f..ff830e0 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -Copyright (c) 2019-2020, Badwolf Authors +Copyright (c) 2019-2021, Badwolf Authors All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index 8dd6cf2..d2f194b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Minimalist and privacy-oriented WebKitGTK+ browser. Homepage: ``` -Copyright © 2019-2020 Badwolf Authors +Copyright © 2019-2021 Badwolf Authors SPDX-License-Identifier: BSD-3-Clause ``` diff --git a/badwolf.c b/badwolf.c index bad849d..bf5d183 100644 --- a/badwolf.c +++ b/badwolf.c @@ -1,5 +1,5 @@ // BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser -// Copyright © 2019-2020 Badwolf Authors +// Copyright © 2019-2021 Badwolf Authors // SPDX-License-Identifier: BSD-3-Clause #include "badwolf.h" diff --git a/keybindings.c b/keybindings.c index 13f2a48..bfc8f7a 100644 --- a/keybindings.c +++ b/keybindings.c @@ -1,5 +1,5 @@ // BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser -// Copyright © 2019-2020 Badwolf Authors +// Copyright © 2019-2021 Badwolf Authors // SPDX-License-Identifier: BSD-3-Clause #include "keybindings.h" @@ -42,7 +42,7 @@ badwolf_about_dialog(GtkWindow *main_window, gpointer user_data) "SPDX-License-Identifier: BSD-3-Clause"); gtk_about_dialog_set_copyright( GTK_ABOUT_DIALOG(about_dialog), - "2019-2020 Badwolf Authors "); + "2019-2021 Badwolf Authors "); gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about_dialog), homepage); gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about_dialog), comments); gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about_dialog), version); diff --git a/uri.c b/uri.c index 912bf86..3cbc1d6 100644 --- a/uri.c +++ b/uri.c @@ -1,5 +1,5 @@ // BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser -// Copyright © 2019-2020 Badwolf Authors +// Copyright © 2019-2021 Badwolf Authors // SPDX-License-Identifier: BSD-3-Clause #include "uri.h" diff --git a/uri_test.c b/uri_test.c index a153817..28bdde9 100644 --- a/uri_test.c +++ b/uri_test.c @@ -1,5 +1,5 @@ // BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser -// Copyright © 2019-2020 Badwolf Authors +// Copyright © 2019-2021 Badwolf Authors // SPDX-License-Identifier: BSD-3-Clause #include "uri.h" diff --git a/usr.bin.badwolf b/usr.bin.badwolf index 0ebce5d..861ee9f 100644 --- a/usr.bin.badwolf +++ b/usr.bin.badwolf @@ -1,5 +1,5 @@ # BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser -# Copyright © 2019-2020 Badwolf Authors +# Copyright © 2019-2021 Badwolf Authors # SPDX-License-Identifier: BSD-3-Clause # # Made on Gentoo Linux with PREFIX=/usr -- cgit v1.3.1-23-gd82d