--- loncom/auth/lonacc.pm 2007/10/02 01:09:59 1.111 +++ loncom/auth/lonacc.pm 2008/03/08 02:45:14 1.114 @@ -1,7 +1,7 @@ # The LearningOnline Network # Cookie Based Access Handler # -# $Id: lonacc.pm,v 1.111 2007/10/02 01:09:59 albertel Exp $ +# $Id: lonacc.pm,v 1.114 2008/03/08 02:45:14 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -57,13 +57,14 @@ sub goodbye { ############################################### sub get_posted_cgi { - my ($r) = @_; + my ($r,$fields) = @_; my $buffer; if ($r->header_in('Content-length')) { $r->read($buffer,$r->header_in('Content-length'),0); } - unless ($buffer=~/^(\-+\w+)\s+Content\-Disposition\:\s*form\-data/si) { + my $content_type = $r->header_in('Content-type'); + if ($content_type !~ m{^multipart/form-data}) { my @pairs=split(/&/,$buffer); my $pair; foreach $pair (@pairs) { @@ -72,10 +73,13 @@ sub get_posted_cgi { $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; + if (ref($fields) eq 'ARRAY') { + next if (!grep(/^\Q$name\E$/,@{$fields})); + } &Apache::loncommon::add_to_env("form.$name",$value); } } else { - my $contentsep=$1; + my ($contentsep) = ($content_type =~ /boundary=\"?([^\";,]+)\"?/); my @lines = split (/\n/,$buffer); my $name=''; my $value=''; @@ -83,7 +87,7 @@ sub get_posted_cgi { my $fmime=''; my $i; for ($i=0;$i<=$#lines;$i++) { - if ($lines[$i]=~/^$contentsep/) { + if ($lines[$i]=~/^--\Q$contentsep\E/) { if ($name) { chomp($value); if ($fname) { @@ -92,6 +96,9 @@ sub get_posted_cgi { } else { $value=~s/\s+$//s; } + if (ref($fields) eq 'ARRAY') { + next if (!grep(/^\Q$name\E$/,@{$fields})); + } &Apache::loncommon::add_to_env("form.$name",$value); } if ($i<$#lines) {