The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

ROADS::CGIvars - A class to unpack and unescape CGI variables

SYNOPSIS

  use ROADS::CGIvars;
  print unescape("http://www.net.lut.ac.uk/%7Emartin/"), "\n";
  cleavargs;
  print $CGIvar{templatetype}, "\n";

DESCRIPTION

This class implements a method for unpacking the CGI parameters bundled with an HTTP request, and a method for turning hex escapes used for illegal characters back into the characters they represent, e.g. '%7E' to the ASCII tilde character.

METHODS

cleaveargs( );

This method reads CGI parameters from the environmental variable QUERY_STRING (if called with the environmental variable REQUEST_METHOD set to 'GET') or from STDIN (if REQUEST_METHOD is 'POST'), and adds them to a hash array in the main program namespace - CGIvars. If the REQUEST_METHOD is neither GET nor POST, the method will bomb out with an HTML error message. If the REQUEST_METHOD is 'POST', the number of bytes to read from STDIN will be set by reading the CONTENT_LENGTH variable from the environment. These environmental variables are normally set by HTTP servers when launching CGI programs.

Entries are added with the CGI variable name as their key, and the CGI value as their value. If an entry already exists, it will be appended to, using a comma ',' as delimiter. Note that if the CGIvar hash array already exists, these new elements will be added to the existing entries. There is no return value from this method.

unescape( escaped_url );

This method takes a string as its parameter and performs hex unescaping on it. In addition, any '+' characters in the string will be replaced with spaces. The result is returned.

BUGS

There is no check on the existance of the CONTENT_LENGTH variable in the process' environment.

SEE ALSO

admin-cgi and cgi-bin programs.

COPYRIGHT

Copyright (c) 1988, Martin Hamilton <martinh@gnu.org> and Jon Knight <jon@net.lut.ac.uk>. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

It was developed by the Department of Computer Studies at Loughborough University of Technology, as part of the ROADS project. ROADS is funded under the UK Electronic Libraries Programme (eLib), the European Commission Telematics for Research Programme, and the TERENA development programme.

AUTHOR

Jon Knight <jon@net.lut.ac.uk>