From fcf2c1a1a5900f51a6e20c6b2391677bf6fb729c Mon Sep 17 00:00:00 2001 From: "kiko%async.com.br" <> Date: Mon, 12 Apr 2004 04:31:44 +0000 Subject: Fix for bug 238865-v1: remove %FORM from page.cgi. Does so, fixing the linked page template and adding a code error for the "bad id provided" case. r=vladd, a=myk. --- page.cgi | 13 +++++++++---- template/en/default/global/code-error.html.tmpl | 5 +++++ template/en/default/pages/linked.html.tmpl | 6 ++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/page.cgi b/page.cgi index b68a9313b..6e78317fc 100755 --- a/page.cgi +++ b/page.cgi @@ -42,14 +42,19 @@ Bugzilla->login(); my $cgi = Bugzilla->cgi; -if ($::FORM{'id'}) { +my $id = $cgi->param('id'); +if ($id) { # Remove all dodgy chars, and split into name and ctype. - $::FORM{'id'} =~ s/[^\w\-\.]//g; - $::FORM{'id'} =~ /(.*)\.(.*)/; + $id =~ s/[^\w\-\.]//g; + $id =~ /(.*)\.(.*)/; + if (!$2) { + # if this regexp fails to match completely, something bad came in + ThrowCodeError("bad_page_cgi_id", { "page_id" => $id }); + } my $format = GetFormat("pages/$1", undef, $2); - $vars->{'form'} = \%::FORM; + $cgi->param('id', $id); print $cgi->header($format->{'ctype'}); diff --git a/template/en/default/global/code-error.html.tmpl b/template/en/default/global/code-error.html.tmpl index 342d67102..c5233b8e8 100644 --- a/template/en/default/global/code-error.html.tmpl +++ b/template/en/default/global/code-error.html.tmpl @@ -56,6 +56,11 @@ [% ELSIF error == "authres_unhandled" %] An authorization handler return value was not handled by the login code. + [% ELSIF error == "bad_page_cgi_id" %] + [% title = "Invalid Page ID" %] + The ID [% page_id FILTER html %] is not a + valid page identifier. + [% ELSIF error == "bug_error" %] Trying to retrieve [% terms.bug %] [%+ bug.bug_id FILTER html %] returned the error [% bug.error FILTER html %]. diff --git a/template/en/default/pages/linked.html.tmpl b/template/en/default/pages/linked.html.tmpl index 2a3521a35..fcb5ee9d0 100644 --- a/template/en/default/pages/linked.html.tmpl +++ b/template/en/default/pages/linked.html.tmpl @@ -21,6 +21,8 @@ #%] [% INCLUDE global/header.html.tmpl title = "Your Linkified Text" %] +[% USE Bugzilla %] +[% cgi = Bugzilla.cgi %]

Copy and paste the text below: @@ -30,7 +32,7 @@

-[%- form.text FILTER quoteUrls FILTER html -%]
+[%- cgi.param("text") FILTER quoteUrls FILTER html -%]
 

@@ -45,7 +47,7 @@

-[%- form.text FILTER quoteUrls -%]
+[%- cgi.param("text") FILTER quoteUrls -%]
 

-- cgit v1.2.3-24-g4f1b