From 124c46d598baca86873cf6cccab7ec64b5a599d5 Mon Sep 17 00:00:00 2001 From: Reed Loden Date: Thu, 8 Jul 2010 14:51:28 -0700 Subject: Bug 567981 - Restore ability for page.cgi pages to contain . characters, but don't permit '..' at all. [r=mkanat a=mkanat] --- page.cgi | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'page.cgi') diff --git a/page.cgi b/page.cgi index 5464789e7..a6a198d8b 100755 --- a/page.cgi +++ b/page.cgi @@ -66,9 +66,13 @@ my $template = Bugzilla->template; my $id = $cgi->param('id'); if ($id) { - # Split into name and ctype, but be careful not to allow directory - # traversal. - $id =~ /^([\w\-\/]+)\.(\w+)$/; + # Be careful not to allow directory traversal. + if ($id =~ /\.\./) { + # two dots in a row is bad + ThrowCodeError("bad_page_cgi_id", { "page_id" => $id }); + } + # Split into name and ctype. + $id =~ /^([\w\-\/\.]+)\.(\w+)$/; if (!$2) { # if this regexp fails to match completely, something bad came in ThrowCodeError("bad_page_cgi_id", { "page_id" => $id }); -- cgit v1.2.3-24-g4f1b