From e197631142c0236e59460310aaecb38ccacfad2e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 19 May 2016 19:23:13 +0000 Subject: www: validate and check filenames in URLs We shall ensure links continue working for this. --- lib/PublicInbox/View.pm | 2 +- lib/PublicInbox/WWW.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 326da4cb..2303a1fa 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -262,7 +262,7 @@ sub attach_link ($$$$) { $desc = '' unless defined $desc; $desc = ': '.$desc if $desc; my $sfn; - if (defined $fn && $fn =~ /\A[\w-]+\.[a-z0-9]+\z/) { + if (defined $fn && $fn =~ /\A[\w\.-]+[a-zA-Z0-9]\z/) { $sfn = $fn; } elsif ($ct eq 'text/plain') { $sfn = 'a.txt'; diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index f87f4171..10c2e7ca 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -23,7 +23,7 @@ use PublicInbox::GitHTTPBackend; our $INBOX_RE = qr!\A/([\w\.\-]+)!; our $MID_RE = qr!([^/]+)!; our $END_RE = qr!(T/|t/|R/|t\.mbox(?:\.gz)?|t\.atom|raw|)!; -our $ATTACH_RE = qr!(\d[\.\d]*)-([\w-]+\.[a-z0-9]+)!i; +our $ATTACH_RE = qr!(\d[\.\d]*)-([\w\.-]+[a-zA-Z0-9])!i; sub new { my ($class, $pi_config) = @_; -- cgit v1.2.3-24-ge0c7