about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-04-12 01:06:58 +0000
committerEric Wong <e@80x24.org>2014-04-12 01:21:23 +0000
commit59438d115d1cf52d12258b5d94bae5219daaae41 (patch)
treec62e512a10d5e9e9361319dbc3f30312be185292 /t
parentc4e1a5af31e924077568823ef83d00d1462f5f12 (diff)
downloadpublic-inbox-59438d115d1cf52d12258b5d94bae5219daaae41.tar.gz
MIDs may have strange characters in them, so we need to handle
escaping/unescaping properly to avoid broken links or worse.
Diffstat (limited to 't')
-rw-r--r--t/cgi.t39
1 files changed, 36 insertions, 3 deletions
diff --git a/t/cgi.t b/t/cgi.t
index 39242bce..3ae87981 100644
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -39,9 +39,9 @@ my $cfgpfx = "publicinbox.test";
         }
 }
 
+my $failbox = "$home/fail.mbox";
+local $ENV{PI_FAILBOX} = $failbox;
 {
-        my $failbox = "$home/fail.mbox";
-        local $ENV{PI_FAILBOX} = $failbox;
         local $ENV{HOME} = $home;
         local $ENV{RECIPIENT} = $addr;
 
@@ -126,9 +126,35 @@ EOF
         # more checks in t/feed.t
 }
 
+# message-id pages
 {
         local $ENV{HOME} = $home;
-        my $res = cgi_run("/test/m/blahblah\@example.com.txt");
+        my $slashy_mid = 'slashy/asdf@example.com';
+        my $reply = Email::Simple->new(<<EOF);
+From: You <you\@example.com>
+To: Me <me\@example.com>
+Cc: $addr
+In-Reply-To: <blah\@example.com>
+Message-Id: <$slashy_mid>
+Subject: Re: hihi
+Date: Thu, 01 Jan 1970 00:00:01 +0000
+
+slashy
+EOF
+        my $in = $reply->as_string;
+
+        {
+                local $ENV{HOME} = $home;
+                local $ENV{RECIPIENT} = $addr;
+                run_with_env({PATH => $main_path}, [$mda], \$in);
+        }
+        local $ENV{GIT_DIR} = $maindir;
+
+        my $res = cgi_run("/test/m/slashy%2fasdf%40example.com.txt");
+        like($res->{body}, qr/Message-Id: <\Q$slashy_mid\E>/,
+                "slashy mid.txt hit");
+
+        $res = cgi_run("/test/m/blahblah\@example.com.txt");
         like($res->{body}, qr/Message-Id: <blahblah\@example\.com>/,
                 "mid.txt hit");
 
@@ -151,6 +177,13 @@ EOF
         like($res->{head}, qr/Status: 404 Not Found/, "mid.html miss");
 }
 
+{
+        local $ENV{HOME} = $home;
+        my $res = cgi_run("/test/");
+        like($res->{body}, qr/slashy%2Fasdf%40example\.com/,
+                "slashy URL generated correctly");
+}
+
 done_testing();
 
 sub run_with_env {