1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-21 18:25:41 +03:00
aports/community/vimb/webkit2gtk-4.1.patch

126 lines
4.4 KiB
Diff

Patch-Source: https://github.com/fanglingsu/vimb/pull/727
--
From 409e8efb8a25ced9badaca4130ef71c65a601f89 Mon Sep 17 00:00:00 2001
From: Patrick Steinhardt <ps@pks.im>
Date: Wed, 21 Dec 2022 15:45:58 +0100
Subject: [PATCH 1/2] global: Convert use of `SoupURI` to use `GUri`
The `SoupURI` interface has been deprecated in libsoup 3.0 in favor of
`GUri`, which is part of glib 2.66 and newer. Convert the codebase to
use the latter.
---
src/main.c | 16 +++++++++++-----
src/shortcut.c | 4 ++--
src/util.c | 8 ++++----
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/config.mk b/config.mk
index 081f667..50267ba 100644
--- a/config.mk
+++ b/config.mk
@@ -17,7 +17,7 @@ SRCDIR = src
DOCDIR = doc
# used libs
-LIBS = gtk+-3.0 'webkit2gtk-4.0 >= 2.20.0'
+LIBS = gtk+-3.0 webkit2gtk-4.1
# setup general used CFLAGS
CFLAGS += -std=c99 -pipe -Wall -fPIC
@@ -34,9 +34,9 @@ endif
# flags used to build webextension
EXTTARGET = webext_main.so
-EXTCFLAGS = ${CFLAGS} $(shell pkg-config --cflags webkit2gtk-web-extension-4.0)
+EXTCFLAGS = ${CFLAGS} $(shell pkg-config --cflags webkit2gtk-web-extension-4.1)
EXTCPPFLAGS = $(CPPFLAGS)
-EXTLDFLAGS = $(shell pkg-config --libs webkit2gtk-web-extension-4.0) -shared
+EXTLDFLAGS = $(shell pkg-config --libs webkit2gtk-web-extension-4.1) -shared
# flags used for the main application
CFLAGS += $(shell pkg-config --cflags $(LIBS))
diff --git a/src/main.c b/src/main.c
index 43b470a..48c4a31 100644
--- a/src/main.c
+++ b/src/main.c
@@ -130,19 +130,25 @@ struct Vimb vb;
gboolean vb_download_set_destination(Client *c, WebKitDownload *download,
char *suggested_filename, const char *path)
{
- char *download_path, *dir, *file, *uri, *basename = NULL,
- *decoded_uri = NULL;
- const char *download_uri;
+ char *download_path, *dir, *file, *uri, *basename = NULL;
+
download_path = GET_CHAR(c, "download-path");
if (!suggested_filename || !*suggested_filename) {
+ const char *download_uri;
+ GUri *parsed_uri = NULL;
+ char *decoded_uri;
+
/* Try to find a matching name if there is no suggested filename. */
download_uri = webkit_uri_request_get_uri(webkit_download_get_request(download));
- decoded_uri = soup_uri_decode(download_uri);
+ parsed_uri = g_uri_parse(download_uri, G_URI_FLAGS_NONE, NULL);
+ decoded_uri = g_uri_to_string(parsed_uri);
basename = g_filename_display_basename(decoded_uri);
- g_free(decoded_uri);
suggested_filename = basename;
+
+ g_uri_unref(parsed_uri);
+ g_free(decoded_uri);
}
/* Prepare the path to save the download. */
diff --git a/src/shortcut.c b/src/shortcut.c
index 692b727..bd7e0d4 100644
--- a/src/shortcut.c
+++ b/src/shortcut.c
@@ -92,7 +92,7 @@ char *shortcut_get_uri(Shortcut *sc, const char *string)
max_num = get_max_placeholder(tmpl);
/* if there are only $0 placeholders we don't need to split the parameters */
if (max_num == 0) {
- quoted_param = soup_uri_encode(query, "&+");
+ quoted_param = g_uri_escape_string(query, NULL, TRUE);
uri = util_str_replace("$0", quoted_param, tmpl);
g_free(quoted_param);
@@ -149,7 +149,7 @@ char *shortcut_get_uri(Shortcut *sc, const char *string)
if (token->len) {
char *new;
- quoted_param = soup_uri_encode(token->str, "&+");
+ quoted_param = g_uri_escape_string(token->str, NULL, TRUE);
new = util_str_replace((char[]){'$', current_num + '0', '\0'}, quoted_param, uri);
g_free(quoted_param);
g_free(uri);
diff --git a/src/util.c b/src/util.c
index fb3052a..9986f7a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -787,9 +787,9 @@ char *util_sanitize_filename(char *filename)
*/
char *util_sanitize_uri(const char *uri_str)
{
- SoupURI *uri;
char *sanitized_uri;
char *for_display;
+ GUri *uri;
if (!uri_str) {
return NULL;
@@ -809,9 +809,9 @@ char *util_sanitize_uri(const char *uri_str)
return for_display;
}
- uri = soup_uri_new(for_display);
- sanitized_uri = soup_uri_to_string(uri, FALSE);
- soup_uri_free(uri);
+ uri = g_uri_parse(for_display, G_URI_FLAGS_NONE, NULL);
+ sanitized_uri = g_uri_to_string_partial(uri, G_URI_HIDE_PASSWORD);
+ g_uri_unref(uri);
g_free(for_display);
return sanitized_uri;