我是这里的新手,我希望我能够正确解释我的问题......我有一个 html 表单,它采用文件名和位置,cgi 脚本处理这个输入。文件将类似于:file.ext 和位置将类似于 /some/folder/ 我的问题是,当我尝试解析查询字符串时,字符串中的 & 和 / 被转换为 amp; 和 %2F ,当我尝试打印参数时,它不起作用......这是输出:
testjarName=some.jar&loc=some%2Ffolder&host=r9_7079&action=PatchjarName
some.jar some.jar
amp;loc
some some
amp;host
r9_7079 r9_7079
amp;action
Patch Patch
FILE IS some.jar and LOCAITON IS
file is some.jar
location some
machine is r9_7079
action is Patch
You typed:
有人可以帮忙吗?我也尝试过 param() 调用,但没有帮助。表单输入法是 GET 这是我正在使用的脚本:
#!/usr/local/bin/perl
use CGI qw(:standard);
#print header;
#print start_html('A Simple Example'),
$my_input = $ENV{QUERY_STRING};
print "Content-type: text/html\n\n";
print "";
print "<html><head></title>test</title></head><body>";
print "$ENV{QUERY_STRING}";
@fv_pairs = split /\&/ , $my_input;
foreach $pair (@fv_pairs) {
if($pair=~m/([^=]+)=(.*)/) {
$field = $1;
print "$field";
print "<br>";
$value = $2;
print "$value " ;
$value =~ s/\+/ /g;
print "$value " ;
print "<br>";
$value =~ s/%([\dA-Fa-f]{2})/pack("C", hex($1))/eg;
$INPUT{$field}=$value;
}
}
print "<br><hr>"; print "FILE IS $INPUT{jarName} and LOCAITON IS $INPUT{loc}";
if (param()) {
print "<hr>";
print
"file is ",em(param('jarName')),
p,
"location ",em(join(", ",param('loc'))),
p,
"machine is ",em(param('host')),
p,
"action is ",em(param('action')),
hr;
print "You typed: " . $input{'loc'} . "\n";
}
print "</body></html>";
#print end_html;
请帮忙。提前致谢。