commit: 59f1c5d4dbcebc48d1d408dba0be2959d7970167
parent 9765887719fd5c3f784d30084111243caf90f16f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 4 Feb 2020 09:14:42 +0100
Merge branch 'release-0.5'
Diffstat:
A | .gitlab-ci.yml | 37 | +++++++++++++++++++++++++++++++++++++ |
M | Makefile | 72 | ++++++++++++++++++++++++++++++++++++++++++++++++++---------------------- |
M | README.md | 38 | ++++++++++++++++++++++++++++---------- |
M | badwolf.1 | 2 | +- |
M | badwolf.c | 210 | +++++++++++++++++++++++++++++++++++++++++++++++++------------------------------ |
M | badwolf.h | 14 | +------------- |
M | config.h | 11 | ++++++++++- |
A | decisions.md | 33 | +++++++++++++++++++++++++++++++++ |
M | keybindings.c | 54 | ++++++++++++++++++++++++++++++++++++++++-------------- |
M | po/fr.po | 123 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------- |
M | po/messages.pot | 111 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------ |
A | po/pt_BR.po | 155 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | uri.c | 22 | ++++++++++++++++++++++ |
A | uri.h | 17 | +++++++++++++++++ |
A | uri_test.c | 61 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | usr.bin.badwolf | 81 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
M | version.sh | 1 | - |
17 files changed, 847 insertions(+), 195 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
@@ -0,0 +1,37 @@
+image: archlinux/base:latest
+
+before_script:
+ - pacman -Syu --noconfirm make clang
+
+stages:
+ - lint
+ - test
+ - analysis
+
+test:
+ stage: test
+ script:
+ - pacman -Syu --noconfirm webkit2gtk pkg-config gettext gcc
+ - make CC=gcc test
+ - make clean
+ - make CC=clang test
+ - make install
+
+format:
+ stage: lint
+ script:
+ - pacman -Syu --noconfirm git
+ - make format
+ - git diff --exit-code
+
+scan-build:
+ stage: analysis
+ script:
+ - pacman -Syu --noconfirm webkit2gtk pkg-config gettext gcc
+ - scan-build --use-cc=gcc -o scan-build-gcc make
+ - make clean
+ - scan-build --use-cc=clang -o scan-build-clang make
+ artifacts:
+ paths:
+ - scan-build-gcc/*
+ - scan-build-clang/*
diff --git a/Makefile b/Makefile
@@ -1,43 +1,69 @@
.POSIX:
+# POSIX Makefile with extensions common to *BSD and GNU such as:
+# - Usage of backticks for shell evaluation
+# - Usage of ?= for defining variables when not already defined
+# - Usage of += for appending to a variable
-PREFIX = /usr/local
-BINDIR = $(PREFIX)/bin
-MANDIR = $(PREFIX)/share/man
-DATADIR = $(PREFIX)/share/badwolf
-APPSDIR = $(PREFIX)/share/applications
-PACKAGE = Badwolf
+PACKAGE = Badwolf
+VERSION = 0.5.0-rc.1
+VERSION_FULL = $(VERSION)`./version.sh`
-DEPS = gtk+-3.0 webkit2gtk-4.0
-OBJS = keybindings.o badwolf.o
+PREFIX ?= /usr/local
+BINDIR ?= $(PREFIX)/bin
+MANDIR ?= $(PREFIX)/share/man
+DOCDIR ?= $(PREFIX)/share/doc/badwolf-$(VERSION)
+DATADIR ?= $(PREFIX)/share/badwolf
+APPSDIR ?= $(PREFIX)/share/applications
+
+CC ?= cc
+DBG ?=
+PKGCONFIG ?= pkg-config
+MSGFMT ?= msgfmt
+
+CFLAGS ?= -g -Wall -Wextra -Wconversion -Wsign-conversion -O2
+
+DEPS = gtk+-3.0 webkit2gtk-4.0 libsoup-2.4
+SRCS = uri.c uri_test.c keybindings.c badwolf.c
+OBJS = uri.o keybindings.o badwolf.o
+OBJS_test = uri_test.o
EXE = badwolf
-TRANS = fr.mo
+EXE_test = uri_test
+TRANS = fr.mo pt_BR.mo
+DOCS = usr.bin.badwolf README.md KnowledgeBase.md
-CC = cc
-CFLAGS = -g -Wall -Wextra -Wconversion -Wsign-conversion
-CDEPS = `pkg-config --cflags $(DEPS)` -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_DEFAULT_SOURCE -DVERSION=\"$(shell ./version.sh)\"
-LIBS = `pkg-config --libs $(DEPS)`
+CFLAGS += -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION_FULL)\"
+CFLAGS += `$(PKGCONFIG) --cflags $(DEPS)`
+LIBS = `$(PKGCONFIG) --libs $(DEPS)`
all: $(EXE) $(TRANS)
-po/messages.pot: badwolf.c
- xgettext --keyword=_ --language=C -o $@ --add-comments --sort-output -j --copyright-holder="Haelwenn (lanodan) Monnier <contact+badwolf-copyright@hacktivis.me>" --package-name="$(PACKAGE)" --package-version="$(shell ./version.sh)" --msgid-bugs-address="contact+badwolf-msgid@hacktivis.me" badwolf.c
+po/messages.pot: $(SRCS)
+ xgettext --keyword=_ --language=C --from-code=UTF-8 -o $@ --add-comments --sort-output --copyright-holder="Badwolf Authors <https://hacktivis.me/projects/badwolf>" --package-name="$(PACKAGE)" --package-version="$(VERSION_FULL)" --msgid-bugs-address="contact+badwolf-msgid@hacktivis.me" $(SRCS)
po/%.po: po/messages.pot
- msgmerge --update $@ $<
+ msgmerge --update --backup=off $@ $<
${TRANS}: po/${@:.mo=.po}
mkdir -p locale/${@:.mo=}/LC_MESSAGES
- msgfmt -o locale/${@:.mo=}/LC_MESSAGES/$(PACKAGE).mo po/${@:.mo=.po}
+ $(MSGFMT) -o locale/${@:.mo=}/LC_MESSAGES/$(PACKAGE).mo po/${@:.mo=.po}
badwolf: $(OBJS)
$(CC) -std=c11 -o $@ $(OBJS) $(LDFLAGS) $(LIBS)
.c:
- $(CC) -std=c11 $(CFLAGS) $(CDEPS) $(LDFLAGS) $(LIBS) -o $@ $<
+ $(CC) -std=c11 $(CFLAGS) $(LDFLAGS) $(LIBS) -o $@ $<
.c.o:
- $(CC) -std=c11 $(CFLAGS) $(CDEPS) -c -o $@ $<
+ $(CC) -std=c11 $(CFLAGS) -c -o $@ $<
+uri_test: uri.o uri_test.o
+ $(CC) -std=c11 -o $@ uri.o uri_test.o $(LDFLAGS) $(LIBS)
+ $(DBG) ./$@
+
+.PHONY: test
+test: $(EXE_test)
+
+.PHONY: install
install: all
mkdir -p $(DESTDIR)$(BINDIR)
cp -p badwolf $(DESTDIR)$(BINDIR)/badwolf
@@ -47,11 +73,13 @@ install: all
cp -r locale/ $(DESTDIR)$(DATADIR)
mkdir -p $(DESTDIR)$(APPSDIR)
cp -p badwolf.desktop $(DESTDIR)$(APPSDIR)/
+ mkdir -p $(DESTDIR)$(DOCDIR)
+ cp -p $(DOCS) $(DESTDIR)$(DOCDIR)/
+ @printf '\nNote: An example AppArmor profile has been installed at '$(DOCDIR)/usr.bin.badwolf'\n'
+.PHONY: clean
clean:
- rm -fr locale $(OBJS) $(EXE)
+ rm -fr locale $(OBJS) $(OBJS_test) $(EXE) $(EXE_test)
format: *.c *.h
clang-format -style=file -assume-filename=.clang-format -i *.c *.h
-
-.PHONY: clean install
diff --git a/README.md b/README.md
@@ -1,7 +1,10 @@
# BadWolf
-Minimalist and privacy-oriented WebKitGTK+ browser
+Minimalist and privacy-oriented WebKitGTK+ browser.
+
+Homepage: <https://hacktivis.me/projects/badwolf>
+
```
-Copyright © 2019 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
+Copyright © 2019-2020 Badwolf Authors <https://hacktivis.me/projects/badwolf>
SPDX-License-Identifier: BSD-3-Clause
```
@@ -11,32 +14,47 @@ The name is a reference to BBC’s Doctor Who Tv serie, I took it simply because
Comparing from other small WebKit browsers for unixes found in the wild:
- Independent of environment, should just work if GTK and WebKitGTK does
+- Storing data should be:
+ - explicit and optionnal (ie. Applying preferences doesn't imply Saving to disk)
+ - not queryabe by WebKit (so the web can't use it)
+ - done in a standard format (like XBEL for bookmarks)
- Static UI, no element should be added at runtime, this is to avoid potential tracking via viewport changes
-- Small codebase, right now we are well under 1 000 lines
+- Small codebase, right now we are under 1 500 lines total
- Does not use modal editing (from vi) as that was designed for editing, not browsing
- UTF-8 encoding by default
Motivation from other clients <https://hacktivis.me/articles/www-client%20are%20broken>
+## Contributing
+### Translations
+You need to have gettext installed. If you want a GUI, poedit exists and Weblate is a good web platform that I might consider hosting at some point.
+
+- Syncing POT file with the source code: ``make po/messages.pot``
+- Syncing PO file with the POT file: ``make po/de.po``
+- Initialising a new PO file (example for German, `de_DE`): ``msginit -l de_DE -i po/messages.pot -o po/de.po``
+
## Repositories
### git
- Main: <https://hacktivis.me/git/badwolf/>, <git://hacktivis.me/git/badwolf.git>
- Mirror: <https://gitlab.com/lanodan/badWolf.git>, this one can also be used if you prefer tickets/PRs over emails
-### release tarballs
+### release assets
- Main: <https://hacktivis.me/releases/>
- Mirror: <https://gitlab.com/lanodan/badWolf/tags>
-Files ending in `.sig` are OpenPGP signatures done with my [key](https://hacktivis.me/key.asc)(`DDC9 237C 14CF 6F4D D847 F6B3 90D9 3ACC FEFF 61AE`).
+- `*.tar.*` files are tarballs archives to be extracted with a program like `tar(1)`, GNU tar and LibArchive bsdtar are known to work.
+- `*.sig` files are OpenPGP signatures done with my [key](https://hacktivis.me/key.asc)(`DDC9 237C 14CF 6F4D D847 F6B3 90D9 3ACC FEFF 61AE`).
+- `*.sign` files are minisign (OpenBSD `signify(1)` compatible) signatures, they key used for it can be found at <https://hacktivis.me/release/signify/> as well as other places (feel free to ping me to get it)
## Manual Installation
Dependencies are:
-- [WebKitGTK](https://webkitgtk.org/), only the latest stable will be fully supported
- C11 Compiler (such as clang or gcc)
-- POSIX make (works with GNU or BSD)
-- A pkg-config implementation (pkg-config and pkgconf are supported)
+- [WebKitGTK](https://webkitgtk.org/), only the latest stable is supported
+- POSIX make with extension for shell in variables (works with GNU, {Net,Free,Open}BSD)
+- A pkg-config implementation (pkgconf is recommended)
+- (optionnal) gettext implementation (such as GNU Gettext)
-Compilation is done with `make`, install with `make install`.
+Compilation is done with `make CC=${CC:-cc}`, install with `make install`. An example AppArmor profile is provided at `usr.bin.badwolf`, please do runtime checks before deploying.
## Notes
-Most of the privacy/security stuff will be done with patches against WebKit as quite a lot isn’t into [WebKitSettings](https://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html) and with a generic WebKit extension that should be resuseable.
+Most of the privacy/security stuff will be done with patches against WebKit as quite a lot isn’t into [WebKitSettings](https://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html) and with generic WebKit extensions that should be resuseable.
diff --git a/badwolf.1 b/badwolf.1
@@ -1,5 +1,5 @@
./" BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser
-./" Copyright © 2019 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
+./" Copyright © 2019-2020 Badwolf Authors <https://hacktivis.me/projects/badwolf>
./" SPDX-License-Identifier: BSD-3-Clause
.Dd 2019-10-31
.Dt badwolf 1
diff --git a/badwolf.c b/badwolf.c
@@ -1,16 +1,18 @@
// BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser
-// Copyright © 2019 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
+// Copyright © 2019-2020 Badwolf Authors <https://hacktivis.me/projects/badwolf>
// SPDX-License-Identifier: BSD-3-Clause
#include "badwolf.h"
#include "config.h"
#include "keybindings.h"
+#include "uri.h"
#include <glib/gi18n.h> /* _() and other internationalization/localization helpers */
-#include <glib/gprintf.h> /* g_fprintf() */
+#include <libsoup/soup.h> /* soup* */
#include <locale.h> /* LC_* */
-#include <stdlib.h> /* realpath(), malloc() */
+#include <stdio.h> /* perror(), fprintf() */
+#include <stdlib.h> /* malloc() */
const gchar *homepage = "https://hacktivis.me/projects/badwolf";
const gchar *version = VERSION;
@@ -61,32 +63,6 @@ static void closeCb_clicked(GtkButton *close, gpointer user_data);
static void
notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data);
-gchar *
-badwolf_ensure_uri_scheme(gchar *text, gboolean try_file)
-{
- if(text == NULL) return "about:blank";
-
- char *scheme = g_uri_parse_scheme(text);
-
- if(scheme != NULL) return text;
-
- if(try_file)
- {
- gchar *f;
- char *path;
- path = realpath(text, NULL);
-
- if(path != NULL)
- {
- f = g_strdup_printf("file://%s", path);
- free(path);
- return f;
- }
- }
-
- return g_strdup_printf("http://%s", text);
-}
-
static gboolean
WebViewCb_close(WebKitWebView *webView, gpointer user_data)
{
@@ -115,16 +91,16 @@ WebViewCb_web_process_terminated(WebKitWebView *webView,
switch(reason)
{
case WEBKIT_WEB_PROCESS_CRASHED:
- g_fprintf(stderr, _("the web process crashed.\n"));
- webView_tab_label_change(browser, _("title|Crashed"));
+ fprintf(stderr, "%s", _("the web process crashed.\n"));
+ webView_tab_label_change(browser, _("Crashed"));
break;
case WEBKIT_WEB_PROCESS_EXCEEDED_MEMORY_LIMIT:
- g_fprintf(stderr, _("the web process exceeded the memory limit.\n"));
- webView_tab_label_change(browser, _("title|Out of Memory"));
+ fprintf(stderr, "%s", _("the web process exceeded the memory limit.\n"));
+ webView_tab_label_change(browser, _("Out of Memory"));
break;
default:
- g_fprintf(stderr, _("the web process terminated for an unknown reason.\n"));
- webView_tab_label_change(browser, _("title|Unknown Crash"));
+ fprintf(stderr, "%s", _("the web process terminated for an unknown reason.\n"));
+ webView_tab_label_change(browser, _("Unknown Crash"));
}
return FALSE;
@@ -244,10 +220,9 @@ WebViewCb_notify__estimated_load_progress(WebKitWebView *webView,
gdouble progress;
progress = webkit_web_view_get_estimated_load_progress(browser->webView);
- if(progress == 1)
- {
- progress = 0;
- }
+
+ if(progress >= 1) progress = 0;
+
gtk_entry_set_progress_fraction(GTK_ENTRY(browser->location), progress);
return TRUE;
@@ -305,13 +280,9 @@ WebViewCb_create(WebKitWebView *related_web_view,
struct Client *browser = new_browser(window, NULL, related_web_view);
if(badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser) < 0)
- {
return NULL;
- }
else
- {
return browser->webView;
- }
}
static gboolean
@@ -354,6 +325,82 @@ WebViewCb_decide_policy(WebKitWebView *web_view,
return TRUE;
}
+static char *
+detail_tls_certificate_flags(GTlsCertificateFlags tls_errors)
+{
+ GString *errors = g_string_new(NULL);
+
+ g_string_append_printf(errors,
+ _("Couldn't verify the TLS certificate to ensure a better security of the "
+ "connection. You might want to verify your machine and network.\n\n"));
+
+ if(tls_errors & G_TLS_CERTIFICATE_UNKNOWN_CA)
+ g_string_append_printf(errors, _("Error: The X509 Certificate Authority is unknown.\n"));
+
+ if(tls_errors & G_TLS_CERTIFICATE_BAD_IDENTITY)
+ g_string_append(errors, _("Error: The given identity doesn't match the expected one.\n"));
+
+ if(tls_errors & G_TLS_CERTIFICATE_NOT_ACTIVATED)
+ g_string_append(errors,
+ _("Error: The certificate isn't valid yet. Check your system's clock.\n"));
+
+ if(tls_errors & G_TLS_CERTIFICATE_EXPIRED)
+ g_string_append(errors, _("Error: The certificate has expired. Check your system's clock.\n"));
+
+ if(tls_errors & G_TLS_CERTIFICATE_REVOKED)
+ g_string_append(errors, _("Error: The certificate has been revoked.\n"));
+
+ if(tls_errors & G_TLS_CERTIFICATE_INSECURE)
+ g_string_append(errors, _("Error: The certificate is considered to be insecure.\n"));
+
+ if(tls_errors & G_TLS_CERTIFICATE_GENERIC_ERROR)
+ g_string_append(errors, _("Error: Some unknown error occurred validating the certificate.\n"));
+
+ return g_string_free(errors, FALSE);
+}
+
+static gboolean
+WebViewCb_load_failed_with_tls_errors(WebKitWebView *web_view,
+ gchar *failing_text,
+ GTlsCertificate *certificate,
+ GTlsCertificateFlags errors,
+ gpointer user_data)
+{
+ (void)web_view;
+ (void)certificate;
+ (void)errors;
+ struct Client *browser = (struct Client *)user_data;
+ gchar *error_details = detail_tls_certificate_flags(errors);
+ gint dialog_response;
+ SoupURI *failing_uri = soup_uri_new(failing_text);
+
+ GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(browser->window->main_window),
+ GTK_DIALOG_MODAL & GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_NONE,
+ _("TLS Error for %s."),
+ failing_text);
+ gtk_dialog_add_buttons(
+ GTK_DIALOG(dialog), _("Temporarly Add Exception"), 1, _("Continue"), 0, NULL);
+ gtk_dialog_set_default_response(GTK_DIALOG(dialog), 0);
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s\n", error_details);
+
+ dialog_response = gtk_dialog_run(GTK_DIALOG(dialog));
+
+ if(dialog_response == 1)
+ {
+ webkit_web_context_allow_tls_certificate_for_host(
+ webkit_web_view_get_context(browser->webView), certificate, failing_uri->host);
+ webkit_web_view_reload(browser->webView);
+ }
+
+ soup_uri_free(failing_uri);
+ g_free(error_details);
+ gtk_widget_destroy(dialog);
+
+ return FALSE; /* propagate the event further */
+}
+
static void
web_contextCb_download_started(WebKitWebContext *web_context,
WebKitDownload *download,
@@ -376,28 +423,22 @@ downloadCb_decide_destination(WebKitDownload *download,
gint chooser_response;
GtkWindow *parent_window = GTK_WINDOW(browser->window->main_window);
- GtkWidget *file_dialog = gtk_file_chooser_dialog_new(NULL,
- parent_window,
- GTK_FILE_CHOOSER_ACTION_SAVE,
- _("_Cancel"),
- GTK_RESPONSE_CANCEL,
- _("_Save"),
- GTK_RESPONSE_ACCEPT,
- NULL);
+ GtkFileChooserNative *file_dialog =
+ gtk_file_chooser_native_new(NULL, parent_window, GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL);
GtkFileChooser *file_chooser = GTK_FILE_CHOOSER(file_dialog);
gtk_file_chooser_set_current_name(file_chooser, suggested_filename);
gtk_file_chooser_set_do_overwrite_confirmation(file_chooser, TRUE);
webkit_download_set_allow_overwrite(download, TRUE);
- chooser_response = gtk_dialog_run(GTK_DIALOG(file_dialog));
+ chooser_response = gtk_native_dialog_run(GTK_NATIVE_DIALOG(file_dialog));
if(chooser_response == GTK_RESPONSE_ACCEPT)
webkit_download_set_destination(download, gtk_file_chooser_get_uri(file_chooser));
else
webkit_download_cancel(download);
- gtk_widget_destroy(file_dialog);
+ g_object_unref(file_dialog);
return FALSE; /* Let it propagate */
}
@@ -405,12 +446,10 @@ downloadCb_decide_destination(WebKitDownload *download,
static gboolean
locationCb_activate(GtkEntry *location, gpointer user_data)
{
- char *target_url;
struct Client *browser = (struct Client *)user_data;
- target_url = badwolf_ensure_uri_scheme((char *)gtk_entry_get_text(location), TRUE);
-
- if(target_url != NULL) webkit_web_view_load_uri(browser->webView, target_url);
+ webkit_web_view_load_uri(browser->webView,
+ badwolf_ensure_uri_scheme(gtk_entry_get_text(location), TRUE));
return TRUE;
}
@@ -479,7 +518,7 @@ SearchEntryCb_stop__search(GtkSearchEntry *search, gpointer user_data)
}
struct Client *
-new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web_view)
+new_browser(struct Window *window, const gchar *target_url, WebKitWebView *related_web_view)
{
struct Client *browser = malloc(sizeof(struct Client));
target_url = badwolf_ensure_uri_scheme(target_url, (related_web_view == NULL));
@@ -606,6 +645,10 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web
g_signal_connect(
browser->webView, "permission-request", G_CALLBACK(WebViewCb_permission_request), NULL);
g_signal_connect(browser->webView, "decide-policy", G_CALLBACK(WebViewCb_decide_policy), NULL);
+ g_signal_connect(browser->webView,
+ "load-failed-with-tls-errors",
+ G_CALLBACK(WebViewCb_load_failed_with_tls_errors),
+ browser);
/* signals for WebView's WebContext */
g_signal_connect(G_OBJECT(web_context),
@@ -646,10 +689,7 @@ badwolf_new_tab(GtkNotebook *notebook, struct Client *browser)
gtk_widget_show_all(browser->box);
- if(gtk_notebook_insert_page(notebook, browser->box, NULL, (current_page + 1)) == -1)
- {
- return -1;
- }
+ if(gtk_notebook_insert_page(notebook, browser->box, NULL, (current_page + 1)) == -1) return -1;
gtk_notebook_set_tab_reorderable(notebook, browser->box, TRUE);
gtk_notebook_set_tab_label(notebook, browser->box, badwolf_new_tab_box(title, browser));
@@ -704,9 +744,7 @@ badwolf_get_tab_position(GtkContainer *notebook, GtkWidget *child)
int
main(int argc, char *argv[])
{
- // getting an abort if this one fails to alloc
- struct Window *window = g_malloc(sizeof(struct Window));
-
+ struct Window *window = &(struct Window){NULL};
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, DATADIR "/locale");
bind_textdomain_codeset(PACKAGE, "UTF-8");
@@ -714,20 +752,28 @@ main(int argc, char *argv[])
gtk_init(&argc, &argv);
- g_fprintf(stderr, _("Running Badwolf version: %s\n"), version);
- g_fprintf(stderr,
- _("Buildtime WebKit version: %d.%d.%d\n"),
- WEBKIT_MAJOR_VERSION,
- WEBKIT_MINOR_VERSION,
- WEBKIT_MICRO_VERSION);
- g_fprintf(stderr,
- _("Runtime WebKit version: %d.%d.%d\n"),
- webkit_get_major_version(),
- webkit_get_minor_version(),
- webkit_get_micro_version());
-
- web_extensions_directory = g_build_filename(g_get_user_data_dir(), "badwolf", "webkit-web-extension", NULL);
- g_fprintf(stderr, _("webkit-web-extension directory set to: %s\n"), web_extensions_directory);
+#ifdef BADWOLF_PREFER_DARK_THEME
+ g_object_set(gtk_settings_get_default(),
+ "gtk-application-prefer-dark-theme",
+ BADWOLF_PREFER_DARK_THEME,
+ NULL);
+#endif
+
+ fprintf(stderr, _("Running Badwolf version: %s\n"), version);
+ fprintf(stderr,
+ _("Buildtime WebKit version: %d.%d.%d\n"),
+ WEBKIT_MAJOR_VERSION,
+ WEBKIT_MINOR_VERSION,
+ WEBKIT_MICRO_VERSION);
+ fprintf(stderr,
+ _("Runtime WebKit version: %d.%d.%d\n"),
+ webkit_get_major_version(),
+ webkit_get_minor_version(),
+ webkit_get_micro_version());
+
+ web_extensions_directory =
+ g_build_filename(g_get_user_data_dir(), "badwolf", "webkit-web-extension", NULL);
+ fprintf(stderr, _("webkit-web-extension directory set to: %s\n"), web_extensions_directory);
window->main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
window->notebook = gtk_notebook_new();
@@ -763,5 +809,11 @@ main(int argc, char *argv[])
gtk_widget_show_all(window->main_window);
gtk_main();
+
+#if 0
+ /* TRANSLATOR Ignore this entry. Done for forcing Unicode in xgettext. */
+ _("ø");
+#endif
+
return 0;
}
diff --git a/badwolf.h b/badwolf.h
@@ -30,22 +30,10 @@ struct Client
GtkWidget *search;
};
-/* badwolf_ensure_uri_scheme: tries to add a scheme on a pseudo-URL missing a scheme
- * - gchar text: pseudo-URL missing a scheme
- * - gboolean try_file: when TRUE check try first if it can be a file:// path
- *
- * When `text` isn't exploitable (ie. NULL), returns "about:blank",
- * when the URL seems to be valid, return it,
- * if try_file is TRUE, check if it can be file:// path,
- * some other checks might be added.
- * In the end use the fallback (`http://` for now, might get configuration),
- * might get some safeguard.
- */
-gchar *badwolf_ensure_uri_scheme(gchar *text, gboolean try_file);
GtkWidget *badwolf_new_tab_box(const gchar *title, struct Client *browser);
void webView_tab_label_change(struct Client *browser, const gchar *title);
struct Client *
-new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web_view);
+new_browser(struct Window *window, const gchar *target_url, WebKitWebView *related_web_view);
int badwolf_new_tab(GtkNotebook *notebook, struct Client *browser);
gint badwolf_get_tab_position(GtkContainer *notebook, GtkWidget *child);
#endif /* BADWOLF_H_INCLUDED */
diff --git a/config.h b/config.h
@@ -60,11 +60,14 @@
// clang-format off
#define BADWOLF_WEBKIT_SETTINGS \
"default-charset", "utf-8", \
+ "enable-accelerated-2d-canvas", FALSE, \
"enable-caret-browsing", FALSE, \
"enable-developer-extras", TRUE, \
+ "enable-dns-prefetching", FALSE, \
+ "enable-hyperlink-auditing", FALSE, \
"enable-java", FALSE, \
- "enable-javascript", TRUE, \
"enable-javascript-markup", FALSE, \
+ "enable-javascript", TRUE, \
"enable-plugins", FALSE, \
"javascript-can-access-clipboard", FALSE, \
"javascript-can-open-windows-automatically", FALSE, \
@@ -83,4 +86,10 @@
*/
#define BADWOLF_STATUSLABEL_ELLIPSIZE PANGO_ELLIPSIZE_MIDDLE
+/* BADWOLF_PREFER_DARK_THEME: Overwrites user GtkSettings for gtk-application-prefer-dark-theme
+ * Done as a temporary workaround against https://bugs.webkit.org/show_bug.cgi?id=197947
+ * Remove definition to keep user settings, should only be done once the bug is fixed.
+ */
+#define BADWOLF_PREFER_DARK_THEME FALSE
+
#endif /* CONFIG_H_INCLUDED */
diff --git a/decisions.md b/decisions.md
@@ -0,0 +1,33 @@
+# Decisions taken over the project lifetime
+## What is this?
+See <https://akazlou.com/posts-output/2015-11-09-every-project-should-have-decisions/>
+Bascially, the idea is to have a file in your projects repo, where you record
+the decisions you make over the course of the project's lifetime.
+Rewriting history will not be done but Post-Scriptum notices will.
+
+## 2020-01-08 08:42:00Z : Start of the decisions.md file
+From memory and git log:
+
+- Changelog is done when preparing for a release, it is copied into the git tag description. This means that there isn't a central file and isn't a changelog entry added with commits.
+- OpenPGP is deprecated in favor of signify, reasons being security and portability.
+- Prefer using lower and more standard/ubiquitous layers for implementations, one example is the about information with printf and Gtk Dialog rather than a custom scheme in WebKitGTK.
+ - using GLib instead of POSIX was done at first but the quality/behaviour of GLib (like `g_malloc()` calling `abort()` on errors) reverted this decision.
+- WebKitGTK was picked because it is the only WebKit port which is maintained enough without a bus-factor (consider giving QtWebKit a hand too?).
+- The `.clang-format` file was copied from the one living in my home directory:
+ - function declaration is at the start of the line to allow jumping to it with a simple editor
+ - braces on their own lines to allow for comments space
+ - "tabs for indentation and space for alignement" style is used for flexibility
+- mdoc was picked over other formats for the manpage, as it is implemented in mandoc and GNU groff, much simpler to read/write and transform to other formats (like HTML or Markdown).
+- Markdown was picked over other formats for informal documentation, it is a simple format supported by most forges, a format which is easier to write and parse could be considered
+- Proprietary systems are not supported for their lack of auditability and transparency.
+- C was picked because:
+ 1. I wanted to avoid being limited by binding completeness or model
+ 2. I think it is a good language which is fit for this purpose provided you are careful enough (such as using LLVM to it's full potential for checks)
+ 3. It is portable and doesn't introduces more dependencies than is already needed
+- POSIX was picked for it's portability (only known one where it's absent is Windows but it's not going to be supported)
+- Writing a portable (almost POSIX-only) Makefile with `pkg-config(1)` was picked over other build systems which tend to be over-complicated and rely on only one implementation.
+- Originally the URL entry accepted only valid URLs, this was changed to a bit of heuristics for fixing it when it was entered by the user.
+- No search entry is provided, this is to encourage users to avoid search engines as much as possible, support for SmartBookmarks with keywords (similar to DuckDuckGo/Searx !bangs) will be added after support for suggestions via bookmarks
+- Bookmarks are first-class citizens as they are data explicitely controlled by the user
+- No browsing history is provided, this is to encourage to use and improve bookmarks, it will be added later on with data retention limits, ability to wipe it and non-reachable from WebKit (and so the Wild Web).
+- Javascript is turned off by default with a checkbox to enable it temporarly, Permissions Requests (microphone, geolocation, …) are all denied, something similar to uMatrix and NoScript will eventually be done to fix this
diff --git a/keybindings.c b/keybindings.c
@@ -1,22 +1,48 @@
+// BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser
+// Copyright © 2019-2020 Badwolf Authors <https://hacktivis.me/projects/badwolf>
+// SPDX-License-Identifier: BSD-3-Clause
+
#include "keybindings.h"
#include "badwolf.h"
+#include <glib/gi18n.h> /* _() */
+
+static gboolean
+about_dialogCb_activate_link(GtkAboutDialog *about_dialog, gchar *uri, gpointer user_data)
+{
+ (void)about_dialog;
+ struct Window *window = (struct Window *)user_data;
+
+ badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, uri, NULL));
+
+ gtk_widget_destroy(GTK_WIDGET(about_dialog));
+
+ return TRUE;
+}
+
static void
-badwolf_about_dialog(GtkWindow *main_window)
+badwolf_about_dialog(GtkWindow *main_window, gpointer user_data)
{
- // clang-format off
- gtk_show_about_dialog(
- main_window,
- "license", "SPDX-License-Identifier: BSD-3-Clause",
- "copyright", "2019 Haelwenn (lanodan) Monnier <contact+badwolf@hacktivis.me>",
- "website", homepage,
- "comments", "Minimalist and privacy-oriented WebKitGTK+ browser",
- "version", version,
- //FIXME: "logo-icon-name", g_get_application_name(),
- NULL
- );
- // clang-format on
+ struct Window *window = (struct Window *)user_data;
+ GtkWidget *about_dialog = gtk_about_dialog_new();
+
+ gtk_window_set_transient_for(GTK_WINDOW(about_dialog), main_window);
+ gtk_window_set_destroy_with_parent(GTK_WINDOW(about_dialog), TRUE);
+
+ gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(about_dialog),
+ "SPDX-License-Identifier: BSD-3-Clause");
+ gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about_dialog),
+ "2019 Haelwenn (lanodan) Monnier <contact+badwolf@hacktivis.me>");
+ gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about_dialog), homepage);
+ gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about_dialog),
+ _("Minimalist and privacy-oriented WebKitGTK+ browser"));
+ gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about_dialog), version);
+
+ g_signal_connect(about_dialog, "activate-link", G_CALLBACK(about_dialogCb_activate_link), window);
+
+ (void)gtk_dialog_run(GTK_DIALOG(about_dialog));
+ gtk_widget_destroy(about_dialog);
}
static void
@@ -111,7 +137,7 @@ commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client *
{
switch(((GdkEventKey *)event)->keyval)
{
- case GDK_KEY_F1: badwolf_about_dialog(GTK_WINDOW(window->main_window)); return TRUE;
+ case GDK_KEY_F1: badwolf_about_dialog(GTK_WINDOW(window->main_window), window); return TRUE;
}
}
diff --git a/po/fr.po b/po/fr.po
@@ -1,5 +1,5 @@
# BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser
-# Copyright (C) 2019 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
+# Copyright (C) 2019-2020 Badwolf Authors <https://hacktivis.me/projects/badwolf>
# This file is distributed under the same license as the Badwolf package.
# Haelwenn (lanodan) Monnier <contact@hacktivis.me>, 2019
#
@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Badwolf 0.3.0+gd88f2e7\n"
"Report-Msgid-Bugs-To: contact+badwolf-msgid@hacktivis.me\n"
-"POT-Creation-Date: 2019-10-31 14:09+0100\n"
-"PO-Revision-Date: 2019-05-11 05:03+0200\n"
+"POT-Creation-Date: 2020-02-04 07:54+0100\n"
+"PO-Revision-Date: 2019-12-22 00:57+0100\n"
"Last-Translator: Haelwenn (lanodan) Monnier <contact@hacktivis.me>\n"
"Language-Team: French\n"
"Language: fr\n"
@@ -17,73 +17,138 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-#: badwolf.c:527 badwolf.c:692 badwolf.c:719
+#: badwolf.c:764
#, c-format
msgid "Buildtime WebKit version: %d.%d.%d\n"
msgstr "Version WebKit à la compilation: %d.%d.%d\n"
-#: badwolf.c:457 badwolf.c:621 badwolf.c:643
+#: badwolf.c:384
+msgid "Continue"
+msgstr "Continuer"
+
+#: badwolf.c:334
+msgid ""
+"Couldn't verify the TLS certificate to ensure a better security of the "
+"connection. You might want to verify your machine and network.\n"
+"\n"
+msgstr ""
+"Impossibilité de vérifier le certificat TLS pour assurer une meilleure "
+"sécurité de la connection. Pensez potentiellement à vérifier votre machine "
+"et son réseau.\n"
+"\n"
+
+#: badwolf.c:95
+#, fuzzy
+msgid "Crashed"
+msgstr "Crash"
+
+#: badwolf.c:357
+msgid "Error: Some unknown error occurred validating the certificate.\n"
+msgstr ""
+"Erreur : Une erreur inconnue est apparue pendant la validation du "
+"certificat.\n"
+
+#: badwolf.c:338
+msgid "Error: The X509 Certificate Authority is unknown.\n"
+msgstr "Erreur : L'autorité de certification (CA X509) est inconnue.\n"
+
+#: badwolf.c:351
+msgid "Error: The certificate has been revoked.\n"
+msgstr "Erreur : Le certificat à été révoqué.\n"
+
+#: badwolf.c:348
+msgid "Error: The certificate has expired. Check your system's clock.\n"
+msgstr "Erreur : Le certificat a expiré.\n"
+
+#: badwolf.c:354
+msgid "Error: The certificate is considered to be insecure.\n"
+msgstr "Erreur : Le certificat est considéré comme non-sécurisé.\n"
+
+#: badwolf.c:345
+msgid "Error: The certificate isn't valid yet. Check your system's clock.\n"
+msgstr "Erreur : Le certificat n'est pas encore valide.\n"
+
+#: badwolf.c:341
+msgid "Error: The given identity doesn't match the expected one.\n"
+msgstr "Erreur : L'identité ne correspond pas à celle attendue.\n"
+
+#: keybindings.c:39
+msgid "Minimalist and privacy-oriented WebKitGTK+ browser"
+msgstr "Navigateur WebKitGTK+ minimaliste et orienté vie privée"
+
+#: badwolf.c:686
msgid "New tab"
msgstr "Nouvel onglet"
-#: badwolf.c:549 badwolf.c:714 badwolf.c:740
+#: badwolf.c:786
msgid "Open new tab"
msgstr "Ouvrir un nouvel onglet"
-#: badwolf.c:690 badwolf.c:717
+#: badwolf.c:99
+msgid "Out of Memory"
+msgstr "Dépassement Mémoire"
+
+#: badwolf.c:762
#, c-format
msgid "Running Badwolf version: %s\n"
msgstr "Version de Badwolf: %s\n"
-#: badwolf.c:532 badwolf.c:697 badwolf.c:724
+#: badwolf.c:769
#, c-format
msgid "Runtime WebKit version: %d.%d.%d\n"
msgstr "Version WebKit au lancement: %d.%d.%d\n"
-#: badwolf.c:373 badwolf.c:532
+#: badwolf.c:381
+#, c-format
+msgid "TLS Error for %s."
+msgstr "Erreur TLS pour %s."
+
+#: badwolf.c:384
+msgid "Temporarly Add Exception"
+msgstr "Ajouter Temporairement une Exception"
+
+#: badwolf.c:571
msgid "Toggle javascript"
msgstr "Activer/Désactiver javascript"
-#: badwolf.c:382
-msgid "_Cancel"
-msgstr "A_rrêter"
-
-#: badwolf.c:384
-msgid "_Save"
-msgstr "_Sauvegarder"
+#: badwolf.c:103
+msgid "Unknown Crash"
+msgstr "Crash inconnu"
-#: badwolf.c:413 badwolf.c:572 badwolf.c:573
+#: badwolf.c:612
msgid "search in current page"
msgstr "recherche dans la page courante"
-#: badwolf.c:100 badwolf.c:234 badwolf.c:118
-#, fuzzy
+#: badwolf.c:94
msgid "the web process crashed.\n"
-msgstr "le processus web à cessé de fonctionner.\n"
+msgstr "le processus web a cessé de fonctionner.\n"
-#: badwolf.c:104 badwolf.c:238 badwolf.c:122
-#, fuzzy
+#: badwolf.c:98
msgid "the web process exceeded the memory limit.\n"
-msgstr "le processus web à dépassé la limitation de mémoire.\n"
+msgstr "le processus web a dépassé la limitation de mémoire.\n"
-#: badwolf.c:108 badwolf.c:242 badwolf.c:126
-#, fuzzy
+#: badwolf.c:102
msgid "the web process terminated for an unknown reason.\n"
msgstr "le processus web s’est interrompu pour une raison inconnue.\n"
-#: badwolf.c:101 badwolf.c:235 badwolf.c:119
+#: badwolf.c:95
msgid "title|Crashed"
msgstr "Crash"
-#: badwolf.c:105 badwolf.c:239 badwolf.c:123
+#: badwolf.c:99
msgid "title|Out of Memory"
msgstr "Dépassement Mémoire"
-#: badwolf.c:109 badwolf.c:243 badwolf.c:127
+#: badwolf.c:103
msgid "title|Unknown Crash"
msgstr "Crash inconnu"
-#: badwolf.c:730
+#: badwolf.c:776
#, c-format
msgid "webkit-web-extension directory set to: %s\n"
msgstr "Répertoire webkit-web-extension configuré à %s\n"
+
+#. TRANSLATOR Ignore this entry. Done for forcing Unicode in xgettext.
+#: badwolf.c:815
+msgid "ø"
+msgstr ""
diff --git a/po/messages.pot b/po/messages.pot
@@ -1,14 +1,14 @@
# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR Haelwenn (lanodan) Monnier <contact+badwolf-copyright@hacktivis.me>
+# Copyright (C) YEAR Badwolf Authors <https://hacktivis.me/projects/badwolf>
# This file is distributed under the same license as the Badwolf package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
-"Project-Id-Version: Badwolf 0.3.0+g4b96925\n"
+"Project-Id-Version: Badwolf 0.4.0+g2e84f1d\n"
"Report-Msgid-Bugs-To: contact+badwolf-msgid@hacktivis.me\n"
-"POT-Creation-Date: 2019-10-31 17:40+0100\n"
+"POT-Creation-Date: 2020-02-04 07:54+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,70 +17,131 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: badwolf.c:527 badwolf.c:692 badwolf.c:719
+#: badwolf.c:764
#, c-format
msgid "Buildtime WebKit version: %d.%d.%d\n"
msgstr ""
-#: badwolf.c:457 badwolf.c:621 badwolf.c:643
+#: badwolf.c:384
+msgid "Continue"
+msgstr ""
+
+#: badwolf.c:334
+msgid ""
+"Couldn't verify the TLS certificate to ensure a better security of the "
+"connection. You might want to verify your machine and network.\n"
+"\n"
+msgstr ""
+
+#: badwolf.c:95
+msgid "Crashed"
+msgstr ""
+
+#: badwolf.c:357
+msgid "Error: Some unknown error occurred validating the certificate.\n"
+msgstr ""
+
+#: badwolf.c:338
+msgid "Error: The X509 Certificate Authority is unknown.\n"
+msgstr ""
+
+#: badwolf.c:351
+msgid "Error: The certificate has been revoked.\n"
+msgstr ""
+
+#: badwolf.c:348
+msgid "Error: The certificate has expired. Check your system's clock.\n"
+msgstr ""
+
+#: badwolf.c:354
+msgid "Error: The certificate is considered to be insecure.\n"
+msgstr ""
+
+#: badwolf.c:345
+msgid "Error: The certificate isn't valid yet. Check your system's clock.\n"
+msgstr ""
+
+#: badwolf.c:341
+msgid "Error: The given identity doesn't match the expected one.\n"
+msgstr ""
+
+#: keybindings.c:39
+msgid "Minimalist and privacy-oriented WebKitGTK+ browser"
+msgstr ""
+
+#: badwolf.c:686
msgid "New tab"
msgstr ""
-#: badwolf.c:549 badwolf.c:714 badwolf.c:740
+#: badwolf.c:786
msgid "Open new tab"
msgstr ""
-#: badwolf.c:690 badwolf.c:717
+#: badwolf.c:99
+msgid "Out of Memory"
+msgstr ""
+
+#: badwolf.c:762
#, c-format
msgid "Running Badwolf version: %s\n"
msgstr ""
-#: badwolf.c:532 badwolf.c:697 badwolf.c:724
+#: badwolf.c:769
#, c-format
msgid "Runtime WebKit version: %d.%d.%d\n"
msgstr ""
-#: badwolf.c:373 badwolf.c:532
-msgid "Toggle javascript"
+#: badwolf.c:381
+#, c-format
+msgid "TLS Error for %s."
msgstr ""
-#: badwolf.c:382
-msgid "_Cancel"
+#: badwolf.c:384
+msgid "Temporarly Add Exception"
msgstr ""
-#: badwolf.c:384
-msgid "_Save"
+#: badwolf.c:571
+msgid "Toggle javascript"
msgstr ""
-#: badwolf.c:413 badwolf.c:572 badwolf.c:573
+#: badwolf.c:103
+msgid "Unknown Crash"
+msgstr ""
+
+#: badwolf.c:612
msgid "search in current page"
msgstr ""
-#: badwolf.c:100 badwolf.c:234 badwolf.c:118
+#: badwolf.c:94
msgid "the web process crashed.\n"
msgstr ""
-#: badwolf.c:104 badwolf.c:238 badwolf.c:122
+#: badwolf.c:98
msgid "the web process exceeded the memory limit.\n"
msgstr ""
-#: badwolf.c:108 badwolf.c:242 badwolf.c:126
+#: badwolf.c:102
msgid "the web process terminated for an unknown reason.\n"
msgstr ""
-#: badwolf.c:101 badwolf.c:235 badwolf.c:119
+#: badwolf.c:95
msgid "title|Crashed"
-msgstr "Crashed"
+msgstr ""
-#: badwolf.c:105 badwolf.c:239 badwolf.c:123
+#: badwolf.c:99
msgid "title|Out of Memory"
-msgstr "Out of Memory"
+msgstr ""
-#: badwolf.c:109 badwolf.c:243 badwolf.c:127
+#: badwolf.c:103
msgid "title|Unknown Crash"
-msgstr "Unknown Crash"
+msgstr ""
-#: badwolf.c:730
+#: badwolf.c:776
#, c-format
msgid "webkit-web-extension directory set to: %s\n"
msgstr ""
+
+#. TRANSLATOR Ignore this entry. Done for forcing Unicode in xgettext.
+#: badwolf.c:815
+msgid "ø"
+msgstr ""
diff --git a/po/pt_BR.po b/po/pt_BR.po
@@ -0,0 +1,155 @@
+# BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser
+# Copyright (C) 2020 Badwolf Authors <https://hacktivis.me/projects/badwolf>
+# This file is distributed under the same license as the Badwolf package.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Badwolf 0.4.0+g607300e\n"
+"Report-Msgid-Bugs-To: contact+badwolf-msgid@hacktivis.me\n"
+"POT-Creation-Date: 2020-02-04 07:54+0100\n"
+"PO-Revision-Date: 2020-01-20 22:17-0300\n"
+"Last-Translator: Pedro Lucas Porcellis <porcellis@eletrotupi.com>\n"
+"Language-Team: Brazilian Portuguese\n"
+"Language: pt_BR\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#: badwolf.c:764
+#, c-format
+msgid "Buildtime WebKit version: %d.%d.%d\n"
+msgstr "Versão do WebKit %d.%d.%d\n"
+
+#: badwolf.c:384
+msgid "Continue"
+msgstr "Continuar"
+
+#: badwolf.c:334
+msgid ""
+"Couldn't verify the TLS certificate to ensure a better security of the "
+"connection. You might want to verify your machine and network.\n"
+"\n"
+msgstr ""
+"Não foi possível verificar o certificado TLS para garantir uma melhor "
+"segurança da conexão. Talvez você deva verificar a sua máquina e rede.\n"
+"\n"
+
+#: badwolf.c:95
+#, fuzzy
+msgid "Crashed"
+msgstr "Erro"
+
+#: badwolf.c:357
+msgid "Error: Some unknown error occurred validating the certificate.\n"
+msgstr ""
+"Erro: Algum erro desconhecido ocorreu enquanto validava o certificado.\n"
+
+#: badwolf.c:338
+msgid "Error: The X509 Certificate Authority is unknown.\n"
+msgstr "Erro: A Autoridade de Certificados X509 é desconhecida.\n"
+
+#: badwolf.c:351
+msgid "Error: The certificate has been revoked.\n"
+msgstr "Erro: O certificado foi revogado.\n"
+
+#: badwolf.c:348
+msgid "Error: The certificate has expired. Check your system's clock.\n"
+msgstr ""
+"Erro: O certificado foi expirado. Verifique o relógio do seu sistema.\n"
+
+#: badwolf.c:354
+msgid "Error: The certificate is considered to be insecure.\n"
+msgstr "Erro: O certificado é considerado inseguro.\n"
+
+#: badwolf.c:345
+msgid "Error: The certificate isn't valid yet. Check your system's clock.\n"
+msgstr ""
+"Erro: O certificado não é válido ainda. Verifique o relógio do seu sistema.\n"
+
+#: badwolf.c:341
+msgid "Error: The given identity doesn't match the expected one.\n"
+msgstr "Erro: A identidade não confere com a esperada.\n"
+
+#: keybindings.c:39
+msgid "Minimalist and privacy-oriented WebKitGTK+ browser"
+msgstr "Navegador orientado pela privacidade e minimalismo"
+
+#: badwolf.c:686
+msgid "New tab"
+msgstr "Nova aba"
+
+#: badwolf.c:786
+msgid "Open new tab"
+msgstr "Abrir uma Nova aba"
+
+#: badwolf.c:99
+#, fuzzy
+msgid "Out of Memory"
+msgstr "Sem memória"
+
+#: badwolf.c:762
+#, c-format
+msgid "Running Badwolf version: %s\n"
+msgstr "Rodando versão %s do Badwolf\n"
+
+#: badwolf.c:769
+#, c-format
+msgid "Runtime WebKit version: %d.%d.%d\n"
+msgstr "Versão do WebKit: %d.%d.%d\n"
+
+#: badwolf.c:381
+#, c-format
+msgid "TLS Error for %s."
+msgstr "Erro TLS para %s."
+
+#: badwolf.c:384
+msgid "Temporarly Add Exception"
+msgstr "Temporáriamente adicionar exceção"
+
+#: badwolf.c:571
+msgid "Toggle javascript"
+msgstr "Habilitar Javascript"
+
+#: badwolf.c:103
+#, fuzzy
+msgid "Unknown Crash"
+msgstr "Erro desconhecido"
+
+#: badwolf.c:612
+msgid "search in current page"
+msgstr "buscar na página atual"
+
+#: badwolf.c:94
+msgid "the web process crashed.\n"
+msgstr "o processo web travou.\n"
+
+#: badwolf.c:98
+msgid "the web process exceeded the memory limit.\n"
+msgstr "o processo web excedeu o limite de memória.\n"
+
+#: badwolf.c:102
+msgid "the web process terminated for an unknown reason.\n"
+msgstr "o processo web terminou por uma razão desconhecida.\n"
+
+#: badwolf.c:95
+msgid "title|Crashed"
+msgstr "Erro"
+
+#: badwolf.c:99
+msgid "title|Out of Memory"
+msgstr "Sem memória"
+
+#: badwolf.c:103
+msgid "title|Unknown Crash"
+msgstr "Erro desconhecido"
+
+#: badwolf.c:776
+#, c-format
+msgid "webkit-web-extension directory set to: %s\n"
+msgstr "diretório de extensões configurado para: %s\n"
+
+#. TRANSLATOR Ignore this entry. Done for forcing Unicode in xgettext.
+#: badwolf.c:815
+msgid "ø"
+msgstr "ø"
diff --git a/uri.c b/uri.c
@@ -0,0 +1,22 @@
+// BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser
+// Copyright © 2019-2020 Badwolf Authors <https://hacktivis.me/projects/badwolf>
+// SPDX-License-Identifier: BSD-3-Clause
+
+#include "uri.h"
+
+#include <glib.h> /* g_strcmp0() */
+#include <unistd.h> /* access() */
+
+const gchar *
+badwolf_ensure_uri_scheme(const gchar *text, gboolean try_file)
+{
+ const gchar *fallback = "about:blank";
+
+ 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);
+
+ return g_strdup_printf("http://%s", text);
+}
diff --git a/uri.h b/uri.h
@@ -0,0 +1,17 @@
+#ifndef URI_H_INCLUDED
+#define URI_H_INCLUDED
+#include <glib.h>
+
+/* badwolf_ensure_uri_scheme: tries to add a scheme on a pseudo-URL missing a scheme
+ * - gchar text: pseudo-URL missing a scheme
+ * - gboolean try_file: when TRUE check try first if it can be a file:// path
+ *
+ * When `text` isn't exploitable (ie. NULL), returns "about:blank",
+ * when the URL seems to be valid, return it,
+ * if try_file is TRUE, check if it can be file:// path,
+ * some other checks might be added.
+ * In the end use the fallback (`http://` for now, might get configuration),
+ * might get some safeguard.
+ */
+const gchar *badwolf_ensure_uri_scheme(const gchar *text, gboolean try_file);
+#endif /* URI_H_INCLUDED */
diff --git a/uri_test.c b/uri_test.c
@@ -0,0 +1,61 @@
+// BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser
+// Copyright © 2019-2020 Badwolf Authors <https://hacktivis.me/projects/badwolf>
+// SPDX-License-Identifier: BSD-3-Clause
+
+#include "uri.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+static void
+badwolf_ensure_uri_scheme_test(void)
+{
+ const gchar *fallback = "about:blank";
+
+ struct
+ {
+ const gchar *expect;
+ const gchar *text;
+ gboolean try_file;
+ } cases[] = {
+ //
+ {"http://uri.c", "http://uri.c", FALSE},
+ {"http://uri.c", "http://uri.c", TRUE},
+ {"file:///dev/null", "file:///dev/null", FALSE},
+ {"file:///dev/null", "file:///dev/null", TRUE},
+ {fallback, NULL, FALSE},
+ {fallback, NULL, TRUE},
+ {fallback, "", FALSE},
+ {fallback, "", TRUE},
+ {"http:///dev/null", "/dev/null", FALSE},
+ {"file:///dev/null", "/dev/null", TRUE},
+ {"http://example.org", "example.org", FALSE},
+ {"http://example.org", "example.org", TRUE},
+ {"http://", "http://", FALSE},
+ {"http://", "http://", TRUE} //
+ };
+
+ for(size_t i = 0; i < sizeof(cases) / sizeof(cases[0]); i++)
+ {
+ g_info("badwolf_ensure_uri_scheme(\"%s\", %s)",
+ cases[i].text,
+ cases[i].try_file ? "TRUE" : "FALSE");
+
+ const gchar *got = badwolf_ensure_uri_scheme(cases[i].text, cases[i].try_file);
+
+ if(g_strcmp0(got, cases[i].expect) != 0)
+ {
+ g_error("expected: \"%s\", got: \"%s\"", cases[i].expect, got);
+ }
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/badwolf_ensure_uri_scheme/test", badwolf_ensure_uri_scheme_test);
+
+ return g_test_run();
+}
diff --git a/usr.bin.badwolf b/usr.bin.badwolf
@@ -0,0 +1,81 @@
+# BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser
+# Copyright © 2019-2020 Badwolf Authors <https://hacktivis.me/projects/badwolf>
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Made on Gentoo Linux with PREFIX=/usr
+#include <tunables/global>
+
+/usr/bin/badwolf {
+ #include <abstractions/enchant>
+ #include <abstractions/gnome>
+ #include <abstractions/ibus>
+ #include <abstractions/uim>
+ #include <abstractions/private-files-strict>
+
+ /usr/bin/badwolf mr,
+ /usr/bin/bwrap Cx,
+ /usr/libexec/webkit2gtk-4.0/WebKitNetworkProcess Cx,
+ /usr/libexec/webkit2gtk-4.0/WebKitWebProcess Cx,
+
+ owner @{PROC}/@{pid}/cmdline r,
+ owner @{PROC}/@{pid}/fd/ r,
+
+ owner @{HOME}/.local/share/badwolf/ r,
+ owner @{HOME}/.local/share/badwolf/** r,
+
+ deny @{HOME}/.local/share/webkitgtk/** rwmlk,
+
+ / r,
+ /** r,
+
+ #include <local/usr.bin.badwolf>
+
+ profile /usr/libexec/webkit2gtk-4.0/WebKitNetworkProcess {
+ #include <abstractions/base>
+ #include <abstractions/nameservice>
+ #include <abstractions/ssl_certs>
+ #include <abstractions/private-files-strict>
+
+ network inet stream,
+ network inet6 stream,
+
+ /usr/libexec/webkit2gtk-4.0/WebKitNetworkProcess mr,
+ /** r,
+ owner /** w,
+ }
+
+ profile /usr/libexec/webkit2gtk-4.0/WebKitWebProcess {
+ #include <abstractions/base>
+ #include <abstractions/fonts>
+ #include <abstractions/gnome>
+ #include <abstractions/gstreamer>
+ #include <abstractions/audio>
+ #include <abstractions/mesa>
+ #include <abstractions/dri-common>
+ #include <abstractions/dri-enumerate>
+
+ /usr/libexec/webkit2gtk-4.0/WebKitWebProcess mr,
+
+ owner @{PROC}/@{pid}/cmdline r,
+ owner @{PROC}/@{pid}/fd/ r,
+
+ /etc/passwd r,
+ /etc/group r,
+ /etc/nsswitch.conf r,
+ /dev/ r,
+
+ owner @{HOME}/.local/share/badwolf/webkit-web-extension/ r,
+ owner @{HOME}/.local/share/badwolf/webkit-web-extension/** mr,
+ }
+
+ profile /usr/bin/bwrap {
+ #include <abstractions/base>
+
+ deny capability sys_admin,
+
+ /usr/bin/bwrap mr,
+ @{PROC}/sys/kernel/overflowuid r,
+ @{PROC}/sys/kernel/overflowgid r,
+ owner @{PROC}/@{pid}/fd/ r,
+ }
+}
diff --git a/version.sh b/version.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-echo -n '0.4.0'
hash=$(git --git-dir="$(dirname $0)/.git" rev-parse --short HEAD 2>/dev/null)
if [ -n "$hash" ]