]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: fix link to raw message from /f/ endpoint
authorEric Wong <e@80x24.org>
Tue, 22 Apr 2014 09:48:53 +0000 (09:48 +0000)
committerEric Wong <e@80x24.org>
Tue, 22 Apr 2014 09:48:53 +0000 (09:48 +0000)
Ugh, at least this has a test...

lib/PublicInbox/View.pm
public-inbox.cgi
t/view.t

index 5b24706c1ecd1d7003f5d13c5601688387cd2128..355d346adbbe54a1adb506f8ba7936b011ced436 100644 (file)
@@ -19,7 +19,7 @@ my $enc_mime = find_encoding('MIME-Header');
 sub as_html {
        my ($class, $mime, $full_pfx) = @_;
 
-       headers_to_html_header($mime) .
+       headers_to_html_header($mime, $full_pfx) .
                multipart_text_as_html($mime, $full_pfx) .
                '</pre></body></html>';
 }
@@ -150,7 +150,7 @@ sub ascii_html {
 }
 
 sub headers_to_html_header {
-       my ($simple) = @_;
+       my ($simple, $full_pfx) = @_;
 
        my $rv = "";
        my @title;
@@ -180,6 +180,9 @@ sub headers_to_html_header {
        if (defined $mid) {
                my ($html, $href) = trim_message_id($mid);
                $rv .= "Message-ID: &lt;$html&gt; ";
+               unless ($full_pfx) {
+                       $href = "../m/$href";
+               }
                $rv .= "(<a href=\"$href.txt\">original</a>)\n";
        }
 
index b9b484be38b5eb584892fcdb3e3670f4b38e7cb0..fc48f2f4416a42c7345ee5c2e4db0cd9f51b57bb 100755 (executable)
@@ -78,7 +78,7 @@ sub main {
        } elsif ($path_info =~ m!$LISTNAME_RE/f/(\S+)\.html\z!o) {
                invalid_list_mid(\%ctx, $1, $2) || get_full_html(\%ctx, $cgi);
 
-       # convenience redirect
+       # convenience redirects, order matters
        } elsif ($path_info =~ m!$LISTNAME_RE/(?:m|f)/(\S+)\z!o) {
                invalid_list_mid(\%ctx, $1, $2) || redirect_mid(\%ctx, $cgi);
 
index 067f9890cc271abc0d1e7195b5d0e823ce677f6d..87f8eeeeea88380bd3b2239af232af83927c9503 100644 (file)
--- a/t/view.t
+++ b/t/view.t
@@ -36,8 +36,8 @@ EOF
        $s = Email::MIME->new($s->as_string);
        my $html = PublicInbox::View->as_html($s);
 
-       # ghetto
-       like($html, qr/<a href="hello%40/s, "MID link present");
+       # ghetto tests
+       like($html, qr!<a href="\.\./m/hello%40!s, "MID link present");
        like($html, qr/hello world\b/, "body present");
        like($html, qr/&gt; keep this inline/, "short quoted text is inline");
        like($html, qr/<a name=[^>]+>&gt; Long and wordy/,
@@ -46,6 +46,7 @@ EOF
        # short page
        my $pfx = "http://example.com/test/f";
        my $short = PublicInbox::View->as_html($s, $pfx);
+       like($short, qr!<a href="hello%40!s, "MID link present");
        like($short, qr/\n&gt; keep this inline/,
                "short quoted text is inline");
        like($short, qr/<a href="\Q$pfx\E#[^>]+>Long and wordy/,