[interchange-cvs] [SCM] Interchange branch, master, updated. REL_5_7_3-19-gf614625

Stefan Hornburg interchange-cvs at icdevgroup.org
Mon Nov 16 21:27:34 UTC 2009


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Interchange".

The branch, master has been updated
       via  f6146256f7220658642bbbac0d12a5d8c41730a2 (commit)
      from  1460ae8c33e65f0d7ab96fe126b874bf9a5b024a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f6146256f7220658642bbbac0d12a5d8c41730a2
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date:   Mon Nov 16 22:15:20 2009 +0100

    move parsing of CGI input to Vend::Dispatch::open_cat (#268)

-----------------------------------------------------------------------

Summary of changes and diff:
 lib/Vend/Data.pm        |    1 -
 lib/Vend/Dispatch.pm    |    6 ++-
 lib/Vend/Interpolate.pm |    3 +-
 lib/Vend/Server.pm      |   90 ++++++++++++++++++++++++++---------------------
 4 files changed, 56 insertions(+), 44 deletions(-)

diff --git a/lib/Vend/Data.pm b/lib/Vend/Data.pm
index 34c03b1..ab64cad 100644
--- a/lib/Vend/Data.pm
+++ b/lib/Vend/Data.pm
@@ -2067,7 +2067,6 @@ sub update_data {
 						$nm,
 						{
 							outfile => $outfile,
-							encoding => 'raw',
 							umask => $::Scratch->{mv_create_umask} || '022',
 							auto_create_dir => $::Scratch->{mv_auto_create_dir},
 							yes => '1',
diff --git a/lib/Vend/Dispatch.pm b/lib/Vend/Dispatch.pm
index b3e376e..378bb9d 100644
--- a/lib/Vend/Dispatch.pm
+++ b/lib/Vend/Dispatch.pm
@@ -1003,7 +1003,7 @@ sub update_global_actions {
 }
 
 sub open_cat {
-	my $cat = shift;
+	my ($cat, $http) = @_;
 
 	if($cat) {
 		%CGI::values = ();
@@ -1155,6 +1155,8 @@ EOF
 	set_file_permissions();
 	umask $Vend::Cfg->{Umask};
 
+	Vend::Server::parse_cgi($http) unless $Global::mod_perl;
+	
 #show_times("end cgi and config mapping") if $Global::ShowTimes;
 	open_database();
 
@@ -1231,7 +1233,7 @@ sub dispatch {
 	adjust_cgi();
 
 	## If returns false then was a 404 no catalog or a delivered image
-	open_cat() or return 1;
+	open_cat('', $http) or return 1;
 
 	Vend::Server::set_process_name("$Vend::Cat $CGI::host");
 
diff --git a/lib/Vend/Interpolate.pm b/lib/Vend/Interpolate.pm
index 6d002fd..993236a 100644
--- a/lib/Vend/Interpolate.pm
+++ b/lib/Vend/Interpolate.pm
@@ -2321,7 +2321,8 @@ sub tag_value_extended {
 			);
 			return $no;
 		}
-#::logDebug(">$file \$CGI::file{$var}" . uneval($opt)); 
+#::logDebug(">$file \$CGI::file{$var}" . uneval($opt));
+		$opt->{encoding} ||= $CGI::file_encoding{$var};
 		Vend::Util::writefile(">$file", \$CGI::file{$var}, $opt)
 			and return $yes;
 		return $no;
diff --git a/lib/Vend/Server.pm b/lib/Vend/Server.pm
index dbd21e5..af48e5a 100644
--- a/lib/Vend/Server.pm
+++ b/lib/Vend/Server.pm
@@ -247,43 +247,6 @@ EOF
 #::logDebug("CGI::query_string=" . $CGI::query_string);
 #::logDebug("entity=" . ${$h->{entity}});
 
-	my $request_method = "\U$CGI::request_method";
-	if ($request_method eq 'POST') {
-#::logDebug("content type header: " . $CGI::content_type);
-		## check for valid content type
-		if ($CGI::content_type =~ m{^(?:multipart/form-data|application/x-www-form-urlencoded|application/xml|application/json)\b}i) {
-			parse_post(\$CGI::query_string, 1)
-				if $Global::TolerateGet;
-			parse_post($h->{entity});
-		}
-		else {
-			## invalid content type for POST
-			## XXX we may want to be a little more forgiving here
-			my $msg = ::get_locale_message(415, "Unsupported Content-Type for POST method");
-			my $content_type = $msg =~ /<html/i ? 'text/html' : 'text/plain';
-			my $len = length($msg);
-			$Vend::StatusLine = <<EOF;
-Status: 415 Unsupported Media Type
-Content-Type: $content_type
-Content-Length: $len
-EOF
-			respond('', \$msg);
-			die($msg);
-		}
-	}
-	elsif ($request_method eq 'PUT') {
-#::logDebug("Put operation.");
-		parse_post(\$CGI::query_string);
-		$CGI::put_ref = $h->{entity};
-#::logDebug("Put contents: $$CGI::put_ref");
-		$$CGI::put_ref =~ s/^\s*--+\s+begin\s+content\s+--+\r?\n//i;
-		$$CGI::put_ref =~ s/^\r?\n--+\s+end\s+content\s+--+\s*$//i;
-	}
-	else {
-		 parse_post(\$CGI::query_string);
-	}
-
-
 #::logDebug("Check robot UA=$Global::RobotUA IP=$Global::RobotIP");
 	if ($Global::RobotIP and $CGI::remote_addr =~ $Global::RobotIP) {
 #::logDebug("It is a robot by IP!");
@@ -332,6 +295,46 @@ sub store_cgi_kv {
 	}
 }
 
+sub parse_cgi {
+	my $h = shift;
+
+	my $request_method = "\U$CGI::request_method";
+	if ($request_method eq 'POST') {
+#::logDebug("content type header: " . $CGI::content_type);
+		## check for valid content type
+		if ($CGI::content_type =~ m{^(?:multipart/form-data|application/x-www-form-urlencoded|application/xml|application/json)\b}i) {
+			parse_post(\$CGI::query_string, 1)
+				if $Global::TolerateGet;
+			parse_post($h->{entity});
+		}
+		else {
+			## invalid content type for POST
+			## XXX we may want to be a little more forgiving here
+			my $msg = ::get_locale_message(415, "Unsupported Content-Type for POST method");
+			my $content_type = $msg =~ /<html/i ? 'text/html' : 'text/plain';
+			my $len = length($msg);
+			$Vend::StatusLine = <<EOF;
+Status: 415 Unsupported Media Type
+Content-Type: $content_type
+Content-Length: $len
+EOF
+			respond('', \$msg);
+			die($msg);
+		}
+	}
+	elsif ($request_method eq 'PUT') {
+#::logDebug("Put operation.");
+		parse_post(\$CGI::query_string);
+		$CGI::put_ref = $h->{entity};
+#::logDebug("Put contents: $$CGI::put_ref");
+		$$CGI::put_ref =~ s/^\s*--+\s+begin\s+content\s+--+\r?\n//i;
+		$$CGI::put_ref =~ s/^\r?\n--+\s+end\s+content\s+--+\s*$//i;
+	}
+	else {
+		 parse_post(\$CGI::query_string);
+	}
+}
+
 sub parse_post {
 	my ($sref, $is_get) = @_;
 	return unless length $$sref;
@@ -476,13 +479,20 @@ sub parse_multipart {
 
 			$content_type ||= 'text/plain';
 			$charset ||= default_charset();
-
-			if ($content_type =~ m{^text/}i) {
-				$charset and $Global::UTF8 and Vend::CharSet::to_internal($charset, \$data);
+			
+			if ($content_type =~ m{^text/}i && $::Variable->{MV_UTF8}) {
+				Vend::CharSet::to_internal($charset, \$data);
+				# use our character set instead of the client's one
+				# to store the file
+				$charset = default_charset();
+			}
+			else {
+				$charset = 'raw';
 			}
 
 			if($filename) {
 				$CGI::file{$param} = $data;
+				$CGI::file_encoding{$param} = $charset;
 				$data = $filename;
 			}
 			else {


hooks/post-receive
-- 
Interchange



More information about the interchange-cvs mailing list