Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Think parsing error

Status
Not open for further replies.

erdog

Technical User
Dec 31, 2006
8
US
I have a script that I use to create news files in html and I include it on my pages using SSI. I have found a weird bug. When I try to post the text (without quotes): "cd " or "cd," or "cd$", I get an Internal Server Error. I think that it has to do with the way it is parsing the text. It doesn't seem to like the letter "c" and "d" and any special character together except for "cd.". I don't know enough perl to understand the contents, only the jist of it. Here is where I think the error occurs:

Code:
sub ReadParse {
    my $buf, @pairs;

    if ($ENV{'REQUEST_METHOD'} eq 'GET') {
        @pairs = split(/&/, $ENV{'QUERY_STRING'});
    } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
        read(STDIN, $buf, $ENV{'CONTENT_LENGTH'});
        @pairs = split(/&/, $buf);
    }

    foreach (@pairs) {
        local($key, $val) = split(/=/);

        $key  =~ tr/+/ /;
        $val =~ tr/+/ /;

        $key  =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        $val =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

        $val =~ s/<!--(.|\n)*-->//g; # Strip SSI

        $in{$key} = $val;
    }
}

You can download the entire script from
Any help would be appreciated.
 
nothing in that (old) code you posted that would cause the error you mention for the reasons you mention.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top