This file is indexed.

/usr/share/perl5/CGI/ValidOp/Base.pm is in libcgi-validop-perl 0.56-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package CGI::ValidOp::Base;
use strict;
use warnings;

use Data::Dumper;
use Carp qw/ croak confess /;

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sub new {
    my $proto = shift;
    my $class = ref $proto || $proto;
    my $self = bless {}, $class;
    $self->init( @_ );
}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# if the calling object has a PROPERTIES method, this
# 1) creates accessor methods for each key returned,
# 2) and calls the method with the value
# if the key is prefixed with a '-', only (2) is performed
sub init {
    my $self = shift;
    my( $args ) = @_;

    return $self unless $self->can( 'PROPERTIES' );
    $self->{ in_init } = 1; # tells other methods that we're not baked yet
    my $config = $self->PROPERTIES;
    for( keys %$config ) {
        $self->method( $_ )
            unless $_ =~ /^-/;
        ( my $prop = $_ ) =~ s/^-//;
        $self->$prop( $config->{ $_ }); # set default
        $self->$prop( $args->{ $prop })    # set incoming
            if ref $args eq 'HASH' and defined $args->{ $prop };
    }
    delete $self->{ in_init };
    $self;
}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# creates a method to store the property
sub method {
    my $self = shift;
    my( $property ) = @_;

    my $pkg = caller;
    return if $pkg->can( $property );

    no strict 'refs';
    *{ "${ pkg }::$property" } =
        sub {
            my $self = shift;
            my( $value ) = @_;

            if( @_ ) {
                undef $value if defined $value and $value eq '';
                $self->{ $property } = $value;
            }
            return unless defined wantarray;
            return @{ $self->{ $property }}
                if wantarray and ref $self->{ $property } eq 'ARRAY';
            return %{ $self->{ $property }}
                if wantarray and ref $self->{ $property } eq 'HASH';
            $self->{ $property };
        };
    return;
}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# accessor for object name; will accept a scalar word
# or a hashref containing a 'name' key
sub set_name {
    my $self = shift;
    my( $args ) = @_;

    my %e = (
        api     => q/ERROR:  set_name() API./,
        preq    => q/Parameter names are required for all values./,
        regex   => q/Parameter names must contain only letters, numbers, underscores, and square brackets./,
    );

    my $name;
    if( ref $args ) {
        croak $e{ api } unless ref $args eq 'HASH' and keys %$args;
        croak $e{ api } unless grep /^name$/ => keys %$args;
        croak $e{ preq } unless $args->{ name };
        $name = $args->{ name };
    }
    $name ||= $args;

    croak $e{ preq }
        unless $name;
    croak $e{ regex }
        unless $name =~ /^[\w\[\]-]+$/;

    $self->{ name } = $name;
    $self->{ name };
}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# adapted from 'CGI Programming with Perl'
sub is_tainted {
    my $self = shift;
    my( $value ) = @_;

    return unless defined $value;
    my $blank = substr( $value, 0, 0 );
    return not eval { eval "1 || $blank" || 1 };
}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sub error_decoration {
    my $self = shift;
    my( $begin, $end ) = @_;

    # must accept arrayref
    ( $begin, $end ) = @$begin
        if ref $begin eq 'ARRAY';

    # we have to be able to pass undef as the second param
    $end = $begin if ! defined $end and @_ == 1;
    if( @_ ) {
        $self->{ error_decoration } = [ $begin, $end ];
        return( $begin, $end );
    }

    ( $begin, $end ) = @{ $self->{ error_decoration }}
        if $self->{ error_decoration };
    return @{ $self->{ error_decoration }}
        if defined $begin or defined $end;
    return;
};

1;

__END__

=head1 NAME 

CGI::ValidOp::Base - base class for CGI::ValidOp and its associates.

=head1 DESCRIPTION

Provides object and method construction, and other common methods, for other CGI::ValidOp classes.  Should not be used directly; see L<CGI::ValidOp>.

=head1 AUTHOR

Randall Hansen <legless@cpan.org>

=head1 COPYRIGHT

Copyright (c) 2003-2005 Randall Hansen. All rights reserved.

This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html

=cut

# $Id: Base.pm 387 2005-04-21 23:45:27Z soh $