From 22a01f144d28d1835744f03ddc2d03ac00d24d31 Mon Sep 17 00:00:00 2001
From: short <>
Date: Tue, 4 Jan 2005 22:31:06 +0000
Subject: [PATCH] "have_ent" is now modified really only if "detect_ent" is
set. Some semiworking workarounds of arguments in both QUERY_STRING and POST.
Fixed &url_out. +Buggy support of header restart on the reset of
"heading_done".
---
Web.pm | 40 +++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/Web.pm b/Web.pm
index c4dd46d..cf02915 100644
--- a/Web.pm
+++ b/Web.pm
@@ -133,27 +133,31 @@ my($class,%args)=@_;
$W->{"r"}=Apache->request();
$W->{"QUERY_STRING"}=$W->{"r"}->args() || "";
- if ($W->{"QUERY_STRING"}=~/[&]amp;have_ent/)
- { $W->{"have_ent"}=0; }
- elsif ($W->{"QUERY_STRING"}=~ /[&]have_ent/)
- { $W->{"have_ent"}=1; }
- else
- { delete $W->{"have_ent"}; }
- if ($W->{"detect_ent"} && !defined $W->{"have_ent"} && $W->{"r"}->method() eq "GET") {
- $W->{"head"}.='{"web_hostname_sub"}}()."/".($W->{"r"}->uri()=~m#^/*(.*)$#)[0]
- ."?".($W->{"QUERY_STRING"} || "detect_ent_glue=1").'&have_ent=detect')
- .'" />'."\n";
+ if ($W->{"detect_ent"}) {
+ if ($W->{"QUERY_STRING"}=~/[&]amp;have_ent/)
+ { $W->{"have_ent"}=0; }
+ elsif ($W->{"QUERY_STRING"}=~ /[&]have_ent/)
+ { $W->{"have_ent"}=1; }
+ else
+ { delete $W->{"have_ent"}; }
+ if (!defined $W->{"have_ent"} && $W->{"r"}->method() eq "GET") {
+ $W->{"head"}.='{"web_hostname_sub"}}()."/".($W->{"r"}->uri()=~m#^/*(.*)$#)[0]
+ ."?".($W->{"QUERY_STRING"} || "detect_ent_glue=1").'&have_ent=detect')
+ .'" />'."\n";
+ }
}
$W->{"QUERY_STRING"}=~s/([&])amp;/$1/g;
$W->{"r"}->args($W->{"QUERY_STRING"});
+ # Workaround: &CGI::Vars behaves weird if strings passed both as POST data and in: $QUERY_STRING
+ do { $W->{"r"}->args(""); delete $ENV{"QUERY_STRING"}; } if $W->{"r"}->method() eq "POST";
# Do not: $W->{"r"}->args()
# as it parses only QUERY_STRING (not POST data).
$W->{"args"}={ CGI->new($W->{"r"})->Vars() };
- for (keys(%{$W->{"args"}})) {
- my @vals=split /\x00/,$W->{"args"}{$_};
+ for my $name (keys(%{$W->{"args"}})) {
+ my @vals=split /\x00/,$W->{"args"}{$name};
next if @vals<=1;
- $W->{"args"}{$_}=[@vals];
+ $W->{"args"}{$name}=[@vals];
}
do { $W->{$_}=$W->{"r"}->headers_in()->{"Accept"} if !defined $W->{$_}; } for ("accept");
@@ -419,7 +423,7 @@ sub url_out($%)
{
my($url,%args)=@_;
- return if !url_is_local $url;
+ return $url if !url_is_local $url;
$url=top_dir($url,%args) if $url=~m#^/# || $args{"abs"};
my $uri=URI->new($url);
@@ -446,7 +450,7 @@ my($url,$contents,%args)=@_;
$contents=~s#]*>##gi;
$contents=~s###gi;
- $url=url_out($url);
+ $url=url_out($url,%args);
my $r='send_http_header("text/html; charset=$client_charset"); # "Content-type"; do not use header()
}
- return if $W->{"heading_done"}++;
exit if $W->{"r"}->header_only();
return if $W->{"header_only"};
+ # We still can append headers before we put out some text.
+ # FIXME: It is not clean to still append them without overwriting.
+ return if $W->{"heading_done"}++;
if (1) { # || !$msie_major || $msie_major>=4) # TODO:dyn
Wprint ''."\n";
--
1.8.3.1