This file is indexed.

/usr/share/perl5/XML/Handler/CanonXMLWriter.pm is in libxml-perl 0.08-2.

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
#
# Copyright (C) 1998, 1999 Ken MacLeod
# XML::Handler::CanonXMLWriter is free software; you can redistribute
# it and/or modify it under the same terms as Perl itself.
#
# $Id: CanonXMLWriter.pm,v 1.2 1999/12/22 21:15:00 kmacleod Exp $
#

use strict;

package XML::Handler::CanonXMLWriter;
use vars qw{ $VERSION %char_entities };

# will be substituted by make-rel script
$VERSION = "0.08";

%char_entities = (
    "\x09" => '	',
    "\x0a" => '
',
    "\x0d" => '
',
    '&' => '&',
    '<' => '&lt;',
    '>' => '&gt;',
    '"' => '&quot;',
);

sub new {
    my ($class, %args) = @_;

    my $self = \%args;
    return bless $self, $class;
}

sub start_document {
    my $self = shift; my $document = shift;

    $self->{'_text_array'} = [];
}

sub end_document {
    my $self = shift; my $document = shift;

    if (defined $self->{IOHandle}) {
	return ();
    } else {
	my $text = join ('', @{$self->{'_text_array'}});
	undef $self->{'_text_array'};
	return $text;
    }
}

sub start_element {
    my $self = shift; my $element = shift;

    $self->_print('<' . $element->{Name});
    my $key;
    my $attrs = $element->{Attributes};
    foreach $key (sort keys %$attrs) {
	$self->_print(" $key=\"" . $self->_escape($attrs->{$key}) . '"');
    }
    $self->_print('>');
}

sub end_element {
    my $self = shift; my $element = shift;

    $self->_print('</' . $element->{Name} . '>');
}

sub characters {
    my $self = shift; my $characters = shift;

    $self->_print($self->_escape($characters->{Data}));
}

sub ignorable_whitespace {
    my $self = shift; my $characters = shift;

    $self->_print($self->_escape($characters->{Data}));
}

sub processing_instruction {
    my $self = shift; my $pi = shift;

    $self->_print('<?' . $pi->{Target} . ' ' . $pi->{Data} . '?>');
}

sub entity {
    # entities don't occur in text
    return ();
}

sub comment {
    my $self = shift; my $comment = shift;

    if ($self->{PrintComments}) {
	$self->_print('<!--' . $comment->{Data} . '-->');
    } else {
	return ();
    }
}

sub _print {
    my $self = shift; my $string = shift;

    if (defined $self->{IOHandle}) {
	$self->{IOHandle}->print($string);
	return ();
    } else {
	push @{$self->{'_text_array'}}, $string;
    }
}

sub _escape {
    my $self = shift; my $string = shift;

    $string =~ s/([\x09\x0a\x0d&<>"])/$char_entities{$1}/ge;
    return $string;
}

1;

__END__

=head1 NAME

XML::Handler::CanonXMLWriter - output XML in canonical XML format

=head1 SYNOPSIS

 use XML::Handler::CanonXMLWriter;

 $writer = XML::Handler::CanonXMLWriter OPTIONS;
 $parser->parse(Handler => $writer);

=head1 DESCRIPTION

C<XML::Handler::CanonXMLWriter> is a PerlSAX handler that will return
a string or write a stream of canonical XML for an XML instance and it's
content.

C<XML::Handler::CanonXMLWriter> objects hold the options used for
writing the XML objects.  Options can be supplied when the the object
is created,

    $writer = new XML::Handler::CanonXMLWriter PrintComments => 1;

or modified at any time before calling the parser's `C<parse()>' method:

    $writer->{PrintComments} = 0;

=head1 OPTIONS

=over 4

=item IOHandle

IOHandle contains a handle for writing the canonical XML to.  If an
IOHandle is not provided, the canonical XML string will be returned
from `C<parse()>'.

=item PrintComments

By default comments are not written to the output.  Setting comment to
a true value will include comments in the output.

=back

=head1 AUTHOR

Ken MacLeod, ken@bitsko.slc.ut.us

=head1 SEE ALSO

perl(1), PerlSAX

James Clark's Canonical XML definition
<http://www.jclark.com/xml/canonxml.html>

=cut