#!/usr/bin/perl -wT # -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*- # # submit-test: was a submission what it should have been? # # Copyright (c) 2004 by Ian Hickson # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use strict; use HTML::Entities; use URI::Escape; unless ($ENV{PATH_INFO} =~ m|^/([^/]+)/(.*)$|os) { print "Status: 400 Bad Request\nContent-Type: text/plain\n\nThe format is\n .../submit-test/get/what=it&should=look&like (for GET submissions)\n .../submit-test/post/what=it&should=look&like (for POST submissions)"; exit; } my $method = $1; my $passCondition = $2; my $query; if ($method eq 'get') { $query = $ENV{QUERY_STRING}; $query =~ s/\+/ /; $query = uri_unescape($query); } else { local $/ = undef; $query = ; } $query = '' if not defined $query; my $result; if ($passCondition eq $query) { $result = 'PASS'; } else { $result = 'FAIL' } foreach ($result, $method, $passCondition, $query) { $_ = encode_entities($_); } print < Test

Result: $result

Test's expected method: $method

Test's expected result:
------------------------------------------------------------------------
$passCondition
------------------------------------------------------------------------

Test's actual result:
------------------------------------------------------------------------
$query
------------------------------------------------------------------------
END