[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lynx-dev Conversion of special character codes within
From: |
Larry W. Virden |
Subject: |
Re: lynx-dev Conversion of special character codes within |
Date: |
Thu, 24 Sep 1998 14:41:24 -0400 (EDT) |
RFC 1866 covers the topic of encoding the URLs proiperly.
Here's a piece of perl code recently given to me as an example of
how to parse the form data:
# written 02/20/97 by Walter Ian Kaye <address@hidden>
# modified 07/12/97 to handle ';' as well as '&'.
# usage: &TokenizeFormData($querystring,$deplus,$unescape);
sub TokenizeFormData {
local($query,$deplus,$unesc) = @_;
$query =~ s/\r\n$//; # delete any trailing CRLF.
$sep = '&';
@eqarr = split(/=/,$query);
$fields = scalar(@eqarr) - 1;
if ($fields > 1) {
$eqstr = @eqarr[1];
$amptot = scalar(split(/&/,$eqstr)) - 1;
$semtot = scalar(split(/;/,$eqstr)) - 1;
if ($semtot && $semtot > $amptot) {
$sep = ';';
}
@query = split($sep,$query);
}
else {
@query = ($query);
}
foreach $pair (@query) {
@pr = split(/=/,$pair);
if ($deplus) {
@pr[1] = &DePlus(@pr[1]);
}
if ($unesc) {
@pr[1] = &UnEscape(@pr[1]);
}
%args = (%args,@pr);
}
%args;
}
sub DePlus {
local($theval) = @_; # form field value
$theval =~ y/\+/ /; # change pluses to spaces
$theval;
}
sub UnEscape {
local($theval) = @_; # form field value
$theval =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
$theval;
}
--
Larry W. Virden INET: address@hidden
<URL:http://www.tclfaq.wservice.com/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.
- lynx-dev Conversion of special character codes within anchor tags, Bruno Prior, 1998/09/24
- Re: lynx-dev Conversion of special character codes within anchor tags, Greg Marr, 1998/09/24
- RE: lynx-dev Conversion of special character codes within anchor tags, Bruno Prior, 1998/09/24
- RE: lynx-dev Conversion of special character codes within anchor tags, Dave Eaton, 1998/09/24
- RE: lynx-dev Conversion of special character codes within anchor tags, Greg Marr, 1998/09/25
- Re: lynx-dev Conversion of special character codes within anchor tags, David Woolley, 1998/09/26
- Re: lynx-dev Conversion of special character codes within anchor tags, Al Gilman, 1998/09/26
- Re: lynx-dev Conversion of special character codes within,
Larry W. Virden <=
Re: lynx-dev Conversion of special character codes within anchor tags, David Woolley, 1998/09/26