user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] support protocol-relative URLs in publicinbox.$LISTNAME.url
@ 2016-02-26  3:03 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-02-26  3:03 UTC (permalink / raw)
  To: meta

All URL generation in dynamic HTTP pages should be capable of
generating "https" or "http" URLs depending on the user's
preference.
---
 lib/PublicInbox/ExtMsg.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm
index 912a675..6356c32 100644
--- a/lib/PublicInbox/ExtMsg.pm
+++ b/lib/PublicInbox/ExtMsg.pm
@@ -26,6 +26,8 @@ sub ext_msg {
 	my $pi_config = $ctx->{pi_config};
 	my $listname = $ctx->{listname};
 	my $mid = $ctx->{mid};
+	my $cgi = $ctx->{cgi};
+	my $env = $cgi->{env};
 
 	eval { require PublicInbox::Search };
 	my $have_xap = $@ ? 0 : 1;
@@ -43,6 +45,7 @@ sub ext_msg {
 		defined $url or next;
 
 		$url =~ s!/+\z!!;
+		$url = PublicInbox::Hval::prurl($env, $url);
 
 		# try to find the URL with Xapian to avoid forking
 		if ($have_xap) {
@@ -85,7 +88,6 @@ sub ext_msg {
 
 	eval { require PublicInbox::Msgmap };
 	my $have_mm = $@ ? 0 : 1;
-	my $cgi = $ctx->{cgi};
 	my $base_url = $cgi->base->as_string;
 	if ($have_mm) {
 		my $tmp_mid = $mid;
@@ -137,7 +139,6 @@ again:
 	if (@EXT_URL && index($mid, '@') >= 0) {
 		$code = 300;
 		$s .= "\nPerhaps try an external site:\n\n";
-		my $env = $cgi->{env};
 		foreach my $url (@EXT_URL) {
 			my $u = PublicInbox::Hval::prurl($env, $url);
 			my $r = sprintf($u, $href);
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-02-26  3:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-26  3:03 [PATCH] support protocol-relative URLs in publicinbox.$LISTNAME.url Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).