Package: pastebinit Version: 1.4-4 Followup-For: Bug #799580 pastebinit doesnt really support https. I attach some patches that enables https in the configuration
I will talk with formorer to agree on the best fix for the http -> https redirection -- System Information: Debian Release: stretch/sid APT prefers testing APT policy: (990, 'testing'), (500, 'stable-updates'), (500, 'unstable'), (500, 'stable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.10-3-amd64 (SMP w/4 CPU cores) Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages pastebinit depends on: ii python3 3.4.3-7 Versions of packages pastebinit recommends: ii lsb-release 9.20150917 pastebinit suggests no packages. -- no debconf information
>From 56a7603c25dc4601652ef195be1aab12ac32a55c Mon Sep 17 00:00:00 2001 From: Alberto Fuentes <paj...@gmail.com> Date: Fri, 23 Oct 2015 06:44:29 +0200 Subject: [PATCH 1/3] in python3 SafeConfigParser was renamed to ConfigParser --- pastebinit | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pastebinit b/pastebinit index 4ab945f..246af93 100755 --- a/pastebinit +++ b/pastebinit @@ -21,11 +21,11 @@ from __future__ import print_function import sys if sys.version[0] == "2": - from ConfigParser import SafeConfigParser + from ConfigParser import SafeConfigParser as ConfigParser from urllib import urlencode from urllib import FancyURLopener else: - from configparser import SafeConfigParser + from configparser import ConfigParser from urllib.parse import urlencode from urllib.request import FancyURLopener @@ -98,7 +98,7 @@ try: continue filename = os.path.join(confdir, fileitem) - instance = SafeConfigParser() + instance = ConfigParser() instance.read(filename) if not instance.has_section('pastebin'): -- 2.6.1
>From a1946506ddcfc8d82e501534b4f1d4e04518c3db Mon Sep 17 00:00:00 2001 From: Alberto Fuentes <paj...@gmail.com> Date: Fri, 23 Oct 2015 06:53:55 +0200 Subject: [PATCH 2/3] add https option to the configuration. There wasnt really a way to tell it to use https for a site --- pastebinit | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pastebinit b/pastebinit index 246af93..e9b2752 100755 --- a/pastebinit +++ b/pastebinit @@ -140,8 +140,16 @@ try: params = {} for paste_name, paste_config in pastebind.items(): basename = paste_config.get('pastebin', 'basename') + try: + https = paste_config.get('pastebin','https') + except: + https = False + if basename == website or paste_name == website: - website = "http://%s" % basename + if https: + website = "https://%s" % basename + else: + website = "http://%s" % basename if re.search(paste_config.get('pastebin', 'regexp'), website): if paste_config.has_option('pastebin', 'sizelimit'): -- 2.6.1
>From 42c38ec53e360ea31266adef5ca62053cc231648 Mon Sep 17 00:00:00 2001 From: Alberto Fuentes <paj...@gmail.com> Date: Fri, 23 Oct 2015 06:56:33 +0200 Subject: [PATCH 3/3] Dont hardcode pastes urls, let the configuration files handle them --- README | 2 ++ debian/patches/detect_distro_with_python3.patch | 2 +- pastebin.d/paste.debian.net.conf | 3 ++- pastebinit | 10 +++++----- test.sh | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README b/README index 399316a..128bdd6 100644 --- a/README +++ b/README @@ -32,6 +32,8 @@ identify the pastebin. Only two fields are used in that section: basename, as well as any sub-domains that may be in use. + https - set to 'True' to make the site use https instead of http + THE FORMAT SECTION diff --git a/debian/patches/detect_distro_with_python3.patch b/debian/patches/detect_distro_with_python3.patch index e0737c3..3bc2d6d 100644 --- a/debian/patches/detect_distro_with_python3.patch +++ b/debian/patches/detect_distro_with_python3.patch @@ -11,5 +11,5 @@ Index: pastebinit/pastebinit + import platform + release = platform.linux_distribution()[0].lower() if release == 'debian': - defaultPB = "http://paste.debian.net" + defaultPB = "paste.debian.net" elif release == 'fedora': diff --git a/pastebin.d/paste.debian.net.conf b/pastebin.d/paste.debian.net.conf index a876d72..81d7f73 100644 --- a/pastebin.d/paste.debian.net.conf +++ b/pastebin.d/paste.debian.net.conf @@ -1,6 +1,7 @@ [pastebin] basename = paste.debian.net -regexp = http://paste.debian.net +regexp = https://paste.debian.net +https = True [format] user = poster diff --git a/pastebinit b/pastebinit index e9b2752..4a05b1f 100755 --- a/pastebinit +++ b/pastebinit @@ -30,18 +30,18 @@ else: from urllib.request import FancyURLopener # Set the default pastebin -defaultPB = "http://pastebin.com" +defaultPB = "pastebin.com" # Now try to override it with a distributor pastebin try: import lsb_release release = lsb_release.get_distro_information()['ID'].lower() if release == 'debian': - defaultPB = "http://paste.debian.net" + defaultPB = "paste.debian.net" elif release == 'fedora': - defaultPB = "http://fpaste.org" + defaultPB = "fpaste.org" elif release == 'ubuntu': - defaultPB = "http://paste.ubuntu.com" + defaultPB = "paste.ubuntu.com" except ImportError: pass @@ -248,7 +248,7 @@ try: #Example configuration file string configexample = """\ <pastebinit> -<pastebin>http://paste.debian.net</pastebin> +<pastebin>paste.debian.net</pastebin> <author>A pastebinit user</author> <jabberid>nob...@nowhere.org</jabberid> <format>text</format> diff --git a/test.sh b/test.sh index a919aed..09ee5f9 100755 --- a/test.sh +++ b/test.sh @@ -5,7 +5,7 @@ for interpreter in python python3; do for pastebin in $($interpreter pastebinit -l | egrep "^-" | sed "s/^- //g") do echo "Trying http://$pastebin ($interpreter)" - URL=$(echo "$teststring\n$teststring\n$teststring" | $interpreter pastebinit -b http://$pastebin) + URL=$(echo "$teststring\n$teststring\n$teststring" | $interpreter pastebinit -b $pastebin) if [ "$pastebin" = "paste.ubuntu.org.cn" ]; then out=$(wget -O - -q "$URL" | gzip -d | grep "$teststring") -- 2.6.1