This file is indexed.

/usr/share/perl5/Catalyst/Request/PartData.pm is in libcatalyst-perl 5.90115-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
package Catalyst::Request::PartData;

use Moose;
use HTTP::Headers;
use Encode;

has [qw/raw_data name size/] => (is=>'ro', required=>1);

has headers => (
  is=>'ro',
  required=>1,
  handles=>[qw/content_type content_encoding content_type_charset/]);

sub build_from_part_data {
  my ($class, $c, $part_data) = @_;

  # If the headers are complex, we need to work harder to figure out what to do
  if(my $hdrs = $class->part_data_has_complex_headers($part_data)) {

    # Ok so its one of two possibilities.  If I can inspect the headers and
    # Figure out what to do, the I will return data.  Otherwise I will return
    # a PartData object and expect you do deal with it.
    # For now if I can find a charset in the content type I will just decode and
    # assume I got it right (patches and bug reports welcomed).

    # Any of these headers means I can't decode

    if(
        $hdrs->content_encoding
    ) {
      return $class->new(
        raw_data => $part_data->{data},
        name => $part_data->{name},
        size => $part_data->{size},
        headers => HTTP::Headers->new(%{ $part_data->{headers} }));
    }

    my ($ct, $charset) = $hdrs->content_type_charset;

    if($ct) {
      # Good news, we probably have data we can return.  If there is a charset
      # then use that to decode otherwise use the default decoding.
      if($charset) {
        return  Encode::decode($charset, $part_data->{data})
      } else {
        if($c and $c->encoding and !$c->config->{skip_body_param_unicode_decoding}) {
          return $c->_handle_param_unicode_decoding($part_data->{data});
        } else {
          return $part_data->{data}
        }
      }
    } else {
      # I have no idea what to do with this now..
      return $class->new(
        raw_data => $part_data->{data},
        name => $part_data->{name},
        size => $part_data->{size},
        headers => HTTP::Headers->new(%{ $part_data->{headers} }));
    }
  } else {
    if($c and $c->encoding and !$c->config->{skip_body_param_unicode_decoding}) {
      return $c->_handle_param_unicode_decoding($part_data->{data});
    } else {
      return $part_data->{data}
    }
  }

  return $part_data->{data} unless $class->part_data_has_complex_headers($part_data);
  return $class->new(
    raw_data => $part_data->{data},
    name => $part_data->{name},
    size => $part_data->{size},
    headers => HTTP::Headers->new(%{ $part_data->{headers} }));
}

sub part_data_has_complex_headers {
  my ($class, $part_data) = @_;
  my %h = %{$part_data->{headers}};
  my $hdrs = HTTP::Headers->new(%h);

  # Remove non threatening headers.
  $hdrs->remove_header('Content-Length', 'Expires', 'Last-Modified', 'Content-Language');

  # If we still have more than one (Content-Disposition) header we need to understand
  # that and deal with it.

  return $hdrs->header_field_names > 1 ? $hdrs :0;
}

__PACKAGE__->meta->make_immutable;

=head1 NAME

Catalyst::Request::Upload - handles file upload requests

=head1 SYNOPSIS

    my $data_part = 

To specify where Catalyst should put the temporary files, set the 'uploadtmp'
option in the Catalyst config. If unset, Catalyst will use the system temp dir.

    __PACKAGE__->config( uploadtmp => '/path/to/tmpdir' );

See also L<Catalyst>.

=head1 DESCRIPTION

=head1 ATTRIBUTES

This class defines the following immutable attributes

=head2 raw_data

The raw data as returned via L<HTTP::Body>.

=head2 name

The part name that gets extracted from the content-disposition header.

=head2 size

The raw byte count (over http) of the data.  This is not the same as the character
length

=head2 headers

An L<HTTP::Headers> object that represents the submitted headers of the POST.  This
object will handle the following methods:

=head3 content_type

=head3 content_encoding

=head3 content_type_charset

These three methods are the same as methods described in L<HTTP::Headers>.

=head1 METHODS

=head2 build_from_part_data

Factory method to build an object from part data returned by L<HTTP::Body>

=head2 part_data_has_complex_headers

Returns true if there more than one header (indicates the part data is complex and
contains content type and encoding information.).

=head1 AUTHORS

Catalyst Contributors, see Catalyst.pm

=head1 COPYRIGHT

This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.

=cut