Changeset 16100 for greenstone3


Ignore:
Timestamp:
2008-06-20T19:30:30+12:00 (16 years ago)
Author:
ak19
Message:
  1. Constructor test for upload-collection-file has changed (so that it can call the super class CGI() constructor to process the Multipart post data). For distinguishing the cases where cmd=upload-collection-file, it now no longer tests the line var read from STDIN, as that will only end up reading in the Multipart post data's Boundary string anyway which therefore won't ever match the expected cmd string upload-collection-file. Instead, it now tests for the upload-coll-file case by checking for the start of the Boundary string (--) instead. As the client GLI's RemoteGreenstoneServer.java file has been updated to insert a dummy first Part in the Multipart POST data for the upload-coll-file command, the server side is now able to read the command, all its cgi-args, as well as the file successfully. 2. This perl module now uses package strict which required some minor changes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/web/WEB-INF/cgi/gsdlCGI4gs3.pm

    r16031 r16100  
    11
    22package gsdlCGI4gs3;
     3
     4use strict;
     5no strict 'subs';
     6no strict 'refs'; # allow filehandles to be variables and viceversa
    37
    48use CGI;
    59use Cwd;
    610
    7 @ISA = ('CGI');
     11@gsdlCGI4gs3::ISA = ('CGI');
    812
    913sub new {
    1014    my $class = shift @_;
     15
    1116
    1217    my $self;
    1318    if ((defined $ENV{'REQUEST_METHOD'}) && ($ENV{'REQUEST_METHOD'} eq "POST")) {
    1419    my $line = <STDIN>;
    15     if ((defined $line) && ($line ne "") && ($line !~ /upload-collection-file/)) {
    16         $self = new CGI($line);
     20    # Multipart POST requests' boundaries created by Java's POST method on the client-GLI side
     21    # start with --. If there are other kinds of languages and boundaries we will be dealing
     22    # with, we can list those patterns alongside here in the (), separated by |:
     23    my $multipartPostBoundary = q/^(--)/;
     24
     25    # cmd=upload-collection-file is not read into $line from STDIN, only the boundary (a
     26    # sequence of chars preceeded by --) is encountered. Either we can match on POST requests
     27    # whose cmds contain "download" OR we can look for $line NOT being boundary, to process $line.
     28    # Multipart POST messages are processed by the zero-argument CGI constructor.
     29    if ((defined $line) && ($line ne "") && ($line !~ /$multipartPostBoundary/)) {
     30        $self = new CGI($line);
    1731    }
    1832    else {
    1933        $self = new CGI();
    2034    }
    21     }
     35    }   
    2236    else {
    2337    $self = new CGI();
     
    5569    my $val = $self->SUPER::param($param);
    5670    $val =~ s/[\r\n]+$// if (defined $val);
    57 
     71   
    5872    return $val;
    5973}
     
    304318
    305319    my $prefix_dir = getcwd();
    306 
     320    my $full_dir = &util::filename_cat($prefix_dir,$local_dir);
    307321    if ($prefix_dir !~ m/collect/) {
    308322    $self->generate_error("Trying to delete outside of Greenstone collect: $full_dir");
    309323    }
    310 
    311     my $full_dir = &util::filename_cat($prefix_dir,$local_dir);
    312324
    313325    # Delete recursively
Note: See TracChangeset for help on using the changeset viewer.