X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FUnsubscribe.pm;h=945e7ae77d4c14bdaccfed19363375ad128e4214;hb=95bdac7f09c69036efed537a4d03d5bdd2ae4eb6;hp=97ff97f66eda6729ae42075c28b0e8174e9ed597;hpb=3f779258173530ca88f31e1dc5332f951d2c44cd;p=public-inbox.git diff --git a/lib/PublicInbox/Unsubscribe.pm b/lib/PublicInbox/Unsubscribe.pm index 97ff97f6..945e7ae7 100644 --- a/lib/PublicInbox/Unsubscribe.pm +++ b/lib/PublicInbox/Unsubscribe.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2016 all contributors +# Copyright (C) 2016-2020 all contributors # License: AGPL-3.0+ # # Standalone PSGI app to handle HTTP(s) unsubscribe links generated @@ -12,7 +12,7 @@ use warnings; use Crypt::CBC; use Plack::Util; use MIME::Base64 qw(decode_base64url); -my $CODE_URL = 'git://80x24.org/public-inbox.git'; +my $CODE_URL = 'https://public-inbox.org/public-inbox.git'; my @CT_HTML = ('Content-Type', 'text/html; charset=UTF-8'); sub new { @@ -77,11 +77,12 @@ sub _user_list_addr { 'Missing mailing list name in path component'); } my $user = eval { $self->{cipher}->decrypt(decode_base64url($u)) }; - if (!defined $user || index($user, '@') <= 1) { + if (!defined $user || index($user, '@') < 1) { my $err = quotemeta($@); my $errors = $env->{'psgi.errors'}; $errors->print("error decrypting: $u\n"); $errors->print("$_\n") for split("\n", $err); + $u = Plack::Util::encode_html($u); return r($self, 400, 'Bad request', "Failed to decrypt: $u"); } @@ -135,7 +136,7 @@ sub r { my ($self, $code, $title, @body) = @_; [ $code, [ @CT_HTML ], [ "$title
".
-		join("\n", "$title\n", @body) . '

'. + join("\n", "$title\n", @body) . '
'. "
This page is available under AGPL-3.0+\n" .
 		"git clone $self->{code_url}\n" .
 		qq(Email $self->{contact} if you have any questions).
@@ -150,14 +151,14 @@ sub archive_info {
 	unless ($archive_url) {
 		if (my $config = $self->{pi_config}) {
 			# PublicInbox::Config::lookup
-			my $inbox = $config->lookup($list_addr);
+			my $ibx = $config->lookup($list_addr);
 			# PublicInbox::Inbox::base_url
-			$archive_url = $inbox->base_url if $inbox;
+			$archive_url = $ibx->base_url if $ibx;
 		}
 	}
 
 	# protocol-relative URL:  "//example.com/" => "https://example.com/"
-	if ($archive_url =~ m!\A//!) {
+	if ($archive_url && $archive_url =~ m!\A//!) {
 		$archive_url = "$env->{'psgi.url_scheme'}:$archive_url";
 	}