Ignore:
Timestamp:
2005-11-02T14:24:39+13:00 (18 years ago)
Author:
jrm21
Message:

1) print usage if given -h or --help
2) set language before printing usage for bad options
3) be more careful when using 'eval' statement so we don't execute

any old code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/pluginfo.pl

    r10578 r10825  
    8484    my $blnParseFailed = "false";
    8585    # general options available to all plugins
    86     my $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
    87     # If there are more than one argument left after parsing, it mean user input too many arguments.
    88     # Error occoured  will return 0
    89     if($intArgLeftinAfterParsing > 1)
    90     {
    91     &PrintUsage::print_txt_usage($options, "{pluginfo.params}");
    92     die "\n";
    93     }
     86    my $unparsed_args = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
    9487
    9588    foreach my $strVariable (keys %$hashParsingResult)
    9689    {
    97     eval "\$$strVariable = \$hashParsingResult->{\"\$strVariable\"}";
     90    my $value = $hashParsingResult->{$strVariable};
     91    # test to make sure the variable name is 'safe'
     92    if ($strVariable !~ /^\w+$/) {
     93        die "variable name '$strVariable' isn't safe!";
     94    }
     95    eval "\$$strVariable = \$value";
    9896    }
    9997
     
    118116        $gsprintf::specialoutputencoding=$encoding;
    119117    }
     118    }
     119
     120    # If there are more than one argument left after parsing, it mean user input too many arguments.
     121    # Error occoured  will return 0
     122    if( $unparsed_args > 1 or (@ARGV && $ARGV[0] =~ /^\-+h/) )
     123    {
     124    PrintUsage::print_txt_usage($options, "{pluginfo.params}");
     125    die "\n";
    120126    }
    121127
Note: See TracChangeset for help on using the changeset viewer.