Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Template problem: <%db_cgi_url%> changed to <Û_cgi_url%>

Quote Reply
Template problem: <%db_cgi_url%> changed to <Û_cgi_url%>
Any thoughts on why that might happen? Made an edit to a template via admin, saved it, and every instance of %db in that template changed to Û. I have the same thing in code others have posted, so I know it's not just me. Search had no results...


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Template problem: <%db_cgi_url%> changed to <Û_cgi_url%> In reply to
It also changed <%Description%> to <Þscription%> and <%Category%> to <Êtegory%>.
Possibly related, or not, most all Tags are now unknown, at least on error pages.

OK, narrowed down to the sub I changed for an upload mod.
Maybe someone with better Perl eyes can see what's causing the problem.
First the original:

Code:
sub parse_form{
# --------------------------------------------------------
# Parses the form input and returns a hash with all the name
# value pairs. Removes any field with "---" as a value
# (as this denotes an empty SELECT field.
#
my (@pairs, %in);
my ($buffer, $pair, $name, $value);

if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
}
else {
&cgierr('You cant run this script from telnet/shell.');
}

PAIR: foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
($value eq "---") and next PAIR;
exists $in{$name} ? ($in{$name} .= "~~$value") : ($in{$name} = $value);
}
return %in;
}

And the one used to replace the original:

Code:
sub parse_form{
# --------------------------------------------------------
my (%in);
my ($buffer, $pair, $name, $value);

use CGI;
$query = new CGI;
PAIR: foreach $name ($query->param()) {
$value = $query->param("$name");
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
if ($value eq "---") { next PAIR; }
unless ($value) { next PAIR; }
(exists $in{$name}) ?
($in{$name} .= "~~$value") :
($in{$name} = $value);
}
return %in;
}


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Nov 19, 2009, 8:39 PM
Quote Reply
Re: [PerlFlunkie] Template problem: <%db_cgi_url%> changed to <Û_cgi_url%> In reply to
I didn't fix it, but I solved the problem by using both parsers, renaming the added one as _upload, and changing the add and modify cgi files to use it. So far, so good...


Leonard
aka PerlFlunkie