From 6ade0c3bd4c262cce1b1f42a17ae2163ea803c16 Mon Sep 17 00:00:00 2001 From: geeseven <2334728+geeseven@users.noreply.github.com> Date: Sat, 2 Jan 2021 06:29:54 -0600 Subject: encode URL when checking if it has been bookmarked URLs with '#' were not getting identified correctly when getting checked. Encoding the URL fixes this. --- misc/userscripts/add-nextcloud-bookmarks | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/userscripts/add-nextcloud-bookmarks b/misc/userscripts/add-nextcloud-bookmarks index 4e66620dc..cace1fd32 100755 --- a/misc/userscripts/add-nextcloud-bookmarks +++ b/misc/userscripts/add-nextcloud-bookmarks @@ -42,7 +42,7 @@ from os import environ, path from sys import argv, exit from PyQt5.QtWidgets import QApplication, QInputDialog, QLineEdit -from requests import get, post +from requests import get, post, utils from requests.auth import HTTPBasicAuth @@ -125,7 +125,7 @@ auth = HTTPBasicAuth(settings["user"], settings["password"]) # check if there is already a bookmark for the URL r = get( - "{}?url={}".format(api_url, QUTE_URL), + "{}?url={}".format(api_url, utils.quote(QUTE_URL, safe="")), auth=auth, headers=headers, timeout=(3.05, 27), -- cgit v1.2.3-54-g00ecf From 576de1aa18f76630fdf46ab248bd689786f1d161 Mon Sep 17 00:00:00 2001 From: geeseven <2334728+geeseven@users.noreply.github.com> Date: Sat, 2 Jan 2021 07:39:47 -0600 Subject: clean up URL encoding --- misc/userscripts/add-nextcloud-bookmarks | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/misc/userscripts/add-nextcloud-bookmarks b/misc/userscripts/add-nextcloud-bookmarks index cace1fd32..5da887086 100755 --- a/misc/userscripts/add-nextcloud-bookmarks +++ b/misc/userscripts/add-nextcloud-bookmarks @@ -42,7 +42,7 @@ from os import environ, path from sys import argv, exit from PyQt5.QtWidgets import QApplication, QInputDialog, QLineEdit -from requests import get, post, utils +from requests import get, post from requests.auth import HTTPBasicAuth @@ -120,14 +120,16 @@ tags = settings["tags"].split(",") QUTE_URL = environ["QUTE_URL"] api_url = settings["host"] + "/index.php/apps/bookmarks/public/rest/v2/bookmark" -headers = {"Content-Type": "application/json"} auth = HTTPBasicAuth(settings["user"], settings["password"]) +headers = {"Content-Type": "application/json"} +params = {"url": QUTE_URL} # check if there is already a bookmark for the URL r = get( - "{}?url={}".format(api_url, utils.quote(QUTE_URL, safe="")), + api_url, auth=auth, headers=headers, + params=params, timeout=(3.05, 27), ) if r.status_code != 200: -- cgit v1.2.3-54-g00ecf