Your message dated Mon, 14 Mar 2011 17:35:46 +0000
with message-id <e1pzbgi-0005xm...@franck.debian.org>
and subject line Bug#618335: fixed in libtest-html-w3c-perl 0.03-2
has caused the Debian Bug report #618335,
regarding libtest-html-w3c-perl: diag_html crashes if no sensible results were 
returned from the validator
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact ow...@bugs.debian.org
immediately.)


-- 
618335: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=618335
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems
--- Begin Message ---
Package: libtest-html-w3c-perl
Severity: grave
Tags: upstream
Justification: renders package unusable



-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

If the validator service has returned no sensible output, the code will
find itself dereferencing an undefined value. This should be checked for and 
the underlying 'validator_error' called for sensible output.

The attached file includes a suggested change.
package Test::HTML::W3C;

use strict;
use vars qw($VERSION @EXPORT);
$VERSION = "0.03"; 

=head1 NAME

Test::HTML::W3C - Perform W3C HTML validation testing

=head1 SYNOPSIS

  use Test::HTML::W3C tests => $test_count;
  # or
  use Test::HTML::W3C 'show_detail';
  # or when using both
  use Test::HTML::W3C tests => $test_count, 'show_detail';

  is_valid_markup($my_html_scalar);

  is_valid_file("/path/to/my/file.html");

  is_valid("http://example.com";);

  # Get the underlying WebService:;Validator::W3C::HTML object
  my $validator = validator();

=head1 DESCRIPTION

The purpose of this module is to provide a wide range of testing
utilities.  Various ways to say "ok" with better diagnostics,
facilities to skip tests, test future features and compare complicated
data structures.  While you can do almost anything with a simple
C<ok()> function, it doesn't provide good diagnostic output.

=head1 ABUSE

Please keep in mind that the W3C validation pages and services are
a shared resource. If you plan to do many many tests, please consider
using your own installation of the validation programs, and then use
your local install by modifying the local validtor:

  my $v = validator();
  $v->validator_uri($my_own_validator);

See the documentation for WebService:;Validator::W3C::HTML and the W3C's
site at http://validator.w3.org/ for details

=over 4

=cut

use WebService::Validator::HTML::W3C;
use base qw(Test::Builder::Module);
@EXPORT = qw(
             plan
             diag_html
             is_valid_markup
             is_valid_file
             is_valid
             validator
            );

my $v = WebService::Validator::HTML::W3C->new();
my $not_checked = 1;
my $show_detail = 0;

sub import_extra {
    my ($class, $list) = @_;
    my @other = ();
    my $idx = 0;
    while( $idx <= $#{$list} ) {
        my $item = $list->[$idx];

        if( defined $item and $item eq 'show_detail' ) {
            $show_detail = 1;
            $v = WebService::Validator::HTML::W3C->new(detailed => 1);
        } else {
            push @other, $item;
        }
        $idx++;
    }
    @$list = @other;
}

=item validator();

B<Description:> Returns the underlying WebService::Validator::HTML::W3C object

B<Parameters:> None.

B<Returns:> $validator

=cut

sub validator {
    return $v;
}


=item plan();

B<Description:> Returns the underlying WebService::Validator::HTML::W3C object

B<Parameters:> None.

B<Returns:> $validator

=cut

sub plan {
    __PACKAGE__->builder->plan(@_);
}

sub _check_plan {
    $not_checked = 0;
    if (! __PACKAGE__->builder->has_plan()) {
        plan("no_plan");
    }
}

=item is_valid_markup($markup[, $name]);

B<Description:> is_valid_markup tests whether the text in the provided scalar
value correctly validates according to the W3C specifications. This is useful
if you have markup stored in a scalar that you wish to test that  you might get
from using LWP or WWW::Mechanize for example...

B<Parameters:> $markup, a scalar containing the data to test, $name, an
optional descriptive test name.

B<Returns:> None.

=cut

sub is_valid_markup {
    _check_plan() if $not_checked;
    my ($markup, $message) = @_;
    if ($v->validate_markup($markup)) {
        _result($v, $message);
    } else {
        _validator_err($v, "markup");
    }
}

=item is_valid_file($path[, $name]);

B<Description:> is_valid_file works the same way as is_valid_markup, except that
you can specify the text to validate with the path to a filename. This is useful
if you have pregenerated all your HTML files locally, and now wish to test them.

B<Parameters:> $path, a scalar, $name, an optional descriptive test name.

B<Returns:> None.

=cut

sub is_valid_file {
    my ($file, $message) = @_;
    _check_plan() if $not_checked;
    if ($v->validate_file($file)) {
        _result($v, $message);
    } else {
        _validator_err($v, "file");
    }
}


=item is_valid($url[, $name]);

B<Description:> is_valid, again, works very similarly to the is_valid_file and
is_valid_file, except you specify a document that is already online with its
URL. This can be useful if you wish to periodically test a website or webpage
that dynamically changes over time for example, like a blog or a wiki, without
first saving the html to a file using your browswer, or a utility such as wget.

B<Parameters:> $url, a scalar, $name, an optional descriptive test name.

B<Returns:> None.

=cut

sub is_valid {
    my ($uri, $message) = @_;
    _check_plan() if $not_checked;
    if ($v->validate($uri)) {
       _result($v, $message);
    } else {
        _validator_err($v, "URI");
    }
}

sub _validator_err {
    my ($validator, $type) = @_;
    __PACKAGE__->builder->ok(0, "Failed to validate $type.");
    __PACKAGE__->builder->diag($v->validator_error());
}

sub _result {
    my ($validator, $message) = @_;
    if ($validator->is_valid()) {
        __PACKAGE__->builder->ok(1, $message);
    } else {
        my $num = $validator->num_errors();
        my $plurality = ($num == 1) ? "error" : "errors";
        __PACKAGE__->builder->ok(0, $message . " ($num $plurality).");
    }
}


=item diag_html($url);

B<Description:> If you want to display the actual errors reported by
the service for a particular test, you can use the diag_html function.
Please note that you must have imported 'show_detail' for this to
work properly.

  use Test::HTML::W3C 'show_detail';

  is_valid_markup("<html></html">, "My simple test") or diag_html();

B<Parameters:> $url, a scalar.

B<Returns:> None.

=cut

sub diag_html {
    my $tb = __PACKAGE__->builder();
    if ($show_detail) {
        my $e;
        if ($v->errors()) {
            my @errs = @{$v->errors()};
            foreach my $error ( @errs ) {
                $e .= sprintf("%s at line %d\n", $error->msg, $error->line);
            }
        }
        else {
            $e .= $v->validator_error;
        }
        $tb->diag($e);
    } else {
        $tb->diag("You need to import 'show_detail' in order to call 
diag_html\n");
    }
}


1;

__END__

=back

=head1 SEE ALSO

L<Test::Builder::Module> for creating your own testing modules.

L<Test::More> for another popular testing framework, also based on
Test::Builder

L<Test::Harness> for detils about how test results are interpreted.

=head1 AUTHORS

Victor E<lt>victo...@gmail.come<gt> with inspiration
from the authors of the Test::More and WebService::Validator::W3C:HTML
modules.

=head1 BUGS

See F<http://rt.cpan.org> to report and view bugs.

=head1 COPYRIGHT

Copyright 2006 by Victor E<lt>victo...@gmail.come<gt>.

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

See F<http://www.perl.com/perl/misc/Artistic.html>

--- End Message ---
--- Begin Message ---
Source: libtest-html-w3c-perl
Source-Version: 0.03-2

We believe that the bug you reported is fixed in the latest version of
libtest-html-w3c-perl, which is due to be installed in the Debian FTP archive:

libtest-html-w3c-perl_0.03-2.debian.tar.gz
  to main/libt/libtest-html-w3c-perl/libtest-html-w3c-perl_0.03-2.debian.tar.gz
libtest-html-w3c-perl_0.03-2.dsc
  to main/libt/libtest-html-w3c-perl/libtest-html-w3c-perl_0.03-2.dsc
libtest-html-w3c-perl_0.03-2_all.deb
  to main/libt/libtest-html-w3c-perl/libtest-html-w3c-perl_0.03-2_all.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 618...@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Nicholas Bamber <nicho...@periapt.co.uk> (supplier of updated 
libtest-html-w3c-perl package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmas...@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Mon, 14 Mar 2011 13:34:09 +0000
Source: libtest-html-w3c-perl
Binary: libtest-html-w3c-perl
Architecture: all source
Version: 0.03-2
Distribution: unstable
Urgency: low
Maintainer: Debian Perl Group <pkg-perl-maintain...@lists.alioth.debian.org>
Changed-By: Nicholas Bamber <nicho...@periapt.co.uk>
Closes: 618335
Description: 
 libtest-html-w3c-perl - wrapper around W3C HTML validation testing service
Changes: 
 libtest-html-w3c-perl (0.03-2) unstable; urgency=low
 .
   * Handle case where no sensible output returned from validator.
     Previously this caused the 'diag_html' method to crash. (Closes: #618335)
Checksums-Sha1: 
 c91fdff89126bc4ac57189df2f661f8c68cc6d91 2102 libtest-html-w3c-perl_0.03-2.dsc
 7cc62d197920adeb4deed0593974a6780df8236b 2453 
libtest-html-w3c-perl_0.03-2.debian.tar.gz
 bcf4b3df277bda100de7a00fa51934dfdfbd1bcb 8502 
libtest-html-w3c-perl_0.03-2_all.deb
Checksums-Sha256: 
 bdd97359fab874ff52ca470e878e7e324028b254d8d0d50269d52dce64ce06d0 2102 
libtest-html-w3c-perl_0.03-2.dsc
 61f9b3e02edd2f4fde0de8d3300769af3d85d6d17159eaebb12636479e93ebee 2453 
libtest-html-w3c-perl_0.03-2.debian.tar.gz
 e24142e1ba8365ddf636a94ff41528e5bbd958c0f464181d8870d4098a1abbc3 8502 
libtest-html-w3c-perl_0.03-2_all.deb
Files: 
 d7a415e4e4f34a2b92f733c784f627e8 2102 perl optional 
libtest-html-w3c-perl_0.03-2.dsc
 6566f33ed4032d712da268619c1af4d8 2453 perl optional 
libtest-html-w3c-perl_0.03-2.debian.tar.gz
 0ebc1fccb7731ca79952110026d96b11 8502 perl optional 
libtest-html-w3c-perl_0.03-2_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCgAGBQJNfk+rAAoJEIATJTTdNH3IZZQQAKyzfSIEM5gA/kfEraRsfaP/
K5KZIAQG3FS/BAdjkfJqcATCzMzMIM0HgCLRPgO258L8NjzmwmaJzPHA6FuOZrDy
6hp0rfZfYW+jWFGunFMSN++17Xn0OT0uLUhMdKJgeBAt6+eAEKrMo8LpakaqUN5v
KsqQmv2l5lBa++o4QS6toONIAqXfgn2DovY+Bl2+AM58wxF2WAp+1dKlcwJqYQwL
cbGgYqu9ffC6QH2lPdVBXs+iM/Jd0E1NgTTaty0sVlpIgxHuYq0rgRH3OADmBMBd
XdBqmByO/3o3OEkwO45o1nrXS7GImQ1OrMQ9ol1cQPsJepW2RMJjx1+o5FmE01an
gevZZ4R47RPZP129w4KloItCdGottH/QBJ69ICq1gr4EcCaNXWJEk7Kk68baBdkd
94sK+JxyyIgZQfzMq34rd6Vx5J4ik0IsJQufNxUz/0evZiIyFjpZNOv1iidgYAC6
yJsQS3O6iboX79ZyoczXGfH9AnRl0YpCSWoHepwvqkwx5Bs97SZsBmPu4uIy+ZvK
cAjpcVgq+fpKPeaR/JMEDp2MISgH7JYqEQr5sYw2VjXrSn0HvRIS8X5gARUpTGn8
8W6/Ucj9OWeE+Qz1R95B/jgrsQiyQ4EIZ/WA2asth/i5fJSJY/byJHvFdA4M+dmG
fnDIyAT6SFj12u5AF84s
=W4ML
-----END PGP SIGNATURE-----



--- End Message ---

Reply via email to