This file is indexed.

/usr/share/perl5/HTML/HTML5/Parser/Error.pm is in libhtml-html5-parser-perl 0.301-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
161
162
163
164
165
166
167
168
169
170
package HTML::HTML5::Parser::Error;

use 5.008001;
use strict;
use warnings;

our $VERSION = '0.301';

use overload '""' => \&to_string;

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

sub level
{
	my $self = shift;
	return {
		m     => 'MUST',
		s     => 'SHOULD',
		w     => 'WARN',
		i     => 'INFO',
		u     => undef,
		}->{$self->{level}} || undef;
}

sub layer
{
	my $self = shift;
	return $self->{layer} || undef;
}

sub type
{
	my $self = shift;
	return $self->{type}||undef;
}

sub tag_name
{
	my $self = shift;
	return undef unless $self->{token} && exists $self->{token}{tag_name};
	return $self->{token}{tag_name};
}

sub source_line
{
	my $self = shift;
	
	if (wantarray)
	{
		return ($self->{line}, $self->{column});
	}
	else
	{
		return $self->{line};
	}
}

sub to_string
{
	my $self = shift;
	
	my $msg     = $self->type;
	my $level   = $self->level;
	my $tag     = $self->tag_name;
	my ($l, $c) = $self->source_line;

	my @details;
	push @details, sprintf('complicance: %s', $level) if defined $level;
	push @details, sprintf('line: %d', $l) if defined $l;
	push @details, sprintf('column: %d', $c) if defined $c;
	push @details, sprintf('tag: %s', $tag) if defined $tag;

	if (@details)
	{
		$msg .= " [";
		$msg .= join '; ', @details;
		$msg .= "]";
	}
	
	return $msg;
}

1;

=head1 NAME

HTML::HTML5::Parser::Error - an error that occurred during parsing

=head1 DESCRIPTION

The C<error_handler> and C<errors> methods of C<HTML::HTML5::Parser> generate
C<HTML::HTML5::Parser::Error> objects.

C<HTML::HTML5::Parser::Error> overloads stringification, so can be printed,
matched against regular expressions, etc.

Note that L<HTML::HTML5::Parser> is not a validation tool, and there are many
classes of error that it does not care about, so will not raise.

=head2 Constructor

=over

=item C<< new(level=>$level, type=>$type, token=>$token, ...) >>

Constructs a new C<HTML::HTML5::Parser::Error> object.

=back

=head2 Methods

=over

=item C<level>

Returns the level of error. ('MUST', 'SHOULD', 'WARN', 'INFO' or undef.)

=item C<layer>

Returns the parsing layer involved, often undef. e.g. 'encode'.

=item C<type>

Returns the type of error as a string.

=item C<tag_name>

Returns the tag name (if any).

=item C<source_line>

  ($line, $col) = $error->source_line();
  $line = $error->source_line;
  
In scalar context, C<source_line> returns the line number of the
source code that triggered the error.

In list context, returns a line/column pair. (Tab characters count as
one column, not eight.)

=item C<to_string>

Returns a friendly error string.

=back

=head1 SEE ALSO

L<HTML::HTML5::Parser>.

=head1 AUTHOR

Toby Inkster, E<lt>tobyink@cpan.orgE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2011-2012 by Toby Inkster

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

=head1 DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.