This file is indexed.

/usr/share/perl5/Parse/DebControl/Patch.pm is in libparse-debcontrol-perl 2.005-4.

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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
package Parse::DebControl::Patch;
=pod

=encoding utf-8

=head1 NAME

Parse::DebControl::Patch - Easy OO parsing of debian patch file metadata (DEP3) data

=head1 SYNOPSIS

    use Parse::DebControl::Patch

    $parser = new Parse::DebControl::Patch;

    $data = $parser->parse_mem($control_data, $options);
    $data = $parser->parse_file('./debian/control', $options);
    $data = $parser->parse_web($url, $options);

=head1 DESCRIPTION

    The patch-file metadata specification (DEP3) diverts from the normal debian/control
    rules primarly of the "free-form" field specification. To handle this we most create
    an parser specifically for this format and hardcode these rules direclty into the code.

    As we will always only have one block of data, we will return the hashref directly
    instead of enclosing it into an array.

    The field B<Forwarded> is magic and will always exists in the out data, even if not specified
    in the indata. It can only have three values, I<yes>, I<no>, and I<not-needed>. If not specified
    it will have the value I<yes>.

=head1 COPYRIGHT

Parse::DebControl is copyright 2003,2004 Jay Bonci E<lt>jaybonci@cpan.orgE<gt>.
Parse::DebControl::Patch is copyright 2009 Carl Fürstenberg E<lt>azatoth@gmail.comE<gt>.
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.

=cut
use strict;
use warnings;

use base 'Parse::DebControl';

use Exporter::Lite;


our @EXPORT_OK = qw($Forwared_Yes $Forwared_No $Forwared_NotNeeded);

our $VERSION = '0.1';

sub _parseDataHandle
{
	my ($this, $handle, $options) = @_;

	unless($handle)
	{
		throw Parse::DebControl::Error("_parseDataHandle failed because no handle was given. This is likely a bug in the module");
	}

	if($options->{tryGzip})
	{
		if(my $gunzipped = $this->_tryGzipInflate($handle))
		{
			$handle = new IO::Scalar \$gunzipped
		}
	}

	my $data = $this->_getReadyHash($options);

	my $linenum = 0;
	my $lastfield = "";
    my $begun = 0;
    my $dpatch = 0;
    my $freeform = "";
    my $in_freeform = 0;
    my $freeform_fields = [];

	foreach my $line (<$handle>)
	{
        next if $line =~ /^\s*$/ and not $begun;

        if( $line =~ /^#\s*$/ and not $begun ) {
            $dpatch = 1;
            next;
        }
        if( $line =~ /^#\s$/ and not $begun ) {
            $dpatch = 1;
        }
        $begun = 1;
        if( $dpatch ) {
            unless( $line =~ s/^# // ) {
                throw Parse::DebControl::Error::Parse("We are in dpatch mode, and a non-shell-comment line found", $linenum, $line);
            }
        }

		chomp $line;


		$linenum++;
        if( $in_freeform ) {
            if( $line =~ /^---/ ) {
                # we need to prohibit --- lines in freeform
                last;
            }
            if( $line =~ /^$/ ) {
                chomp $freeform;
                push @$freeform_fields, $freeform;
                $freeform = "";
                $in_freeform = 0;
            } else {
                $freeform .= "$line\n";
            }
            next;
        } else {
            if( $line =~ /^$/ ) {
                $in_freeform = 1;
                $freeform = "";
                next;
            }
        }

        if( $line =~ /^---/ ) {
            last;
        } elsif($line =~ /^[^\t\s]/) {
			#we have a valid key-value pair
			if($line =~ /(.*?)\s*\:\s*(.*)$/)
			{
				my $key = $1;
				my $value = $2;

				if($options->{discardCase})
				{
					$key = lc($key);
				}

				push @{$data->{$key}}, $value;

				$lastfield = $key;
			}else{
				throw Parse::DebControl::Error::Parse('invalid key/value stansa', $linenum, $line);
			}

		} elsif($line =~ /^([\t\s])(.*)/) {
            #appends to previous line

            unless($lastfield)
            {
                throw Parse::DebControl::Error::Parse('indented entry without previous line', $linenum, $line);
            }
			if($2 eq "." ){
				$data->{$lastfield}->[scalar @{$data->{$lastfield}}] .= "\n";
			}else{
				my $val = $2;
				$val =~ s/[\s\t]+$//;
				$data->{$lastfield}->[scalar @{$data->{$lastfield}}] .= "\n$val";
			}
        }else{
            # we'll ignore if junk comes after the metadata usually
            last;
        }

	}

    if( scalar @$freeform_fields ) {
        if( exists $data->{'Description'} ) {
            push @{$data->{'Description'}}, @$freeform_fields;
        } elsif( exists $data->{'Subject'} ) {
            push @{$data->{'Subject'}}, @$freeform_fields;
        } else {
                throw Parse::DebControl::Error::Parse('Freeform field found without any Subject or Description fields');
        }
    }
    if( exists $data->{'Forwarded'} ) {
        $data->{'Forwarded'} = new Parse::DebControl::Patch::Forwarded($data->{'Forwarded'}->[0]);
    } else {
        $data->{'Forwarded'} = new Parse::DebControl::Patch::Forwarded();
    }

	return $data;
}

package Parse::DebControl::Patch::Forwarded;

sub new {
    my ($class, $value) = @_;
    my $this = {};

    my $obj = bless $this, $class;
    $obj->{value} = $value ? $value : 'yes';
    $obj;
}

use overload 'bool' => \&check_bool, '""' => \&get_string, 'cmp' => \&compare;

sub check_bool {
    my ( $self ) = shift;
    if( $self->{value} eq 'no' || $self->{value} eq 'not-needed' ) {
        return 0;
    }
    return 1;
}

sub get_string {
    my ( $self ) = shift;
    return $self->{value};
}

sub compare {
    my $self = shift;
    my $theirs = shift;

    if( $self->{value} eq $theirs ) {
        return 0;
    } elsif( $self->{value} gt $theirs ) {
        return 1;
    }
    return -1;

}

1;