[NUUG fiksgatami] [patch] Avoid some hardcoded fixmystreet.com references

Matthew Somerville matthew at mysociety.org
Mon Jan 12 19:41:32 CET 2009


Petter Reinholdtsen wrote:
> Here is a patch to get rid of some hardcoded fixmystreet.com
> references in the code.  Discovered them during testing.  I expect to
> find some more, and will report those later. :)

Thanks :-) On all but the first though - HTTP redirects must be 
absolute, not relative (RFC2616 14.30). I guess you'll need to add 
OPTION_BASE_URL (if I remember correctly) to the lines.

ATB,
Matthew

> Index: perllib/Page.pm
> ===================================================================
> RCS file: /repos/mysociety/bci/perllib/Page.pm,v
> retrieving revision 1.132
> diff -u -3 -p -r1.132 Page.pm
> --- perllib/Page.pm     10 Jan 2009 18:37:44 -0000      1.132
> +++ perllib/Page.pm     11 Jan 2009 22:00:08 -0000
> @@ -64,11 +64,13 @@ sub do_fastcgi {
>          warn "caught fatal exception: $msg";
>          warn "aborting";
>          ent($msg);
> +        my $contact_email = mySociety::Config::get('CONTACT_EMAIL');
> +
>          print "Status: 500\nContent-Type: text/html; charset=iso-8859-1\n\n",
>                  q(<html><head><title>Sorry! Something's gone wrong.</title></head></html>),
>                  q(<body>),
>                  q(<h1>Sorry! Something's gone wrong.</h1>),
> -                q(<p>Please try again later, or <a href="mailto:team at fixmystreet.com">email us</a> to let us know.</p>),
> +                q(<p>Please try again later, or <a href="mailto:$contact_email">email us</a> to let us know.</p>),
>                  q(<hr>),
>                  q(<p>The text of the error was:</p>),
>                  qq(<blockquote class="errortext">$msg</blockquote>),
> Index: web/index.cgi
> ===================================================================
> RCS file: /repos/mysociety/bci/web/index.cgi,v
> retrieving revision 1.238
> diff -u -3 -p -r1.238 index.cgi
> --- web/index.cgi       10 Jan 2009 18:37:45 -0000      1.238
> +++ web/index.cgi       11 Jan 2009 22:00:08 -0000
> @@ -60,7 +60,7 @@ sub main {
>                  $q->param('phone', $row[6]);
>                  $q->param('partial', $partial);
>              } else {
> -                print $q->redirect(-location => 'http://www.fixmystreet.com/report/' . $id);
> +                print $q->redirect(-location => '/report/' . $id);
>              }
>          }
>      }
> @@ -725,7 +725,7 @@ sub display_location {
>      my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars;
> 
>      if ($input{y} =~ /favicon/) {
> -        print $q->redirect(-location => 'http://www.fixmystreet.com/favicon.ico', -status => 301);
> +        print $q->redirect(-location => '/favicon.ico', -status => 301);
>          return '';
>      }
>      my($error, $easting, $northing);
> Index: web/rss.cgi
> ===================================================================
> RCS file: /repos/mysociety/bci/web/rss.cgi,v
> retrieving revision 1.26
> diff -u -3 -p -r1.26 rss.cgi
> --- web/rss.cgi 8 Dec 2008 10:54:16 -0000       1.26
> +++ web/rss.cgi 11 Jan 2009 22:00:08 -0000
> @@ -42,7 +42,7 @@ sub main {
>      } elsif ($type eq 'all_problems') {
>          $out = mySociety::Alert::generate_rss($type, $xsl, '');
>      } else {
> -        print $q->redirect('http://www.fixmystreet.com/alert');
> +        print $q->redirect('/alert');
>          exit;
>      }
>      print $q->header( -type => 'application/xml; charset=utf-8' );
> @@ -77,7 +77,7 @@ sub rss_local_problems {
>              $error = shift;
>          };
>          unless ($error) {
> -            print $q->redirect(-location => "http://www.fixmystreet.com/rss/$x/$y");
> +            print $q->redirect(-location => "/rss/$x/$y");
>          }
>          return '';
>      } else {



More information about the fiksgatami mailing list