r56006 - in /branches/upstream/libwww-mechanize-perl/current: Changes MANIFEST META.yml lib/WWW/Mechanize.pm lib/WWW/Mechanize/Examples.pod lib/WWW/Mechanize/FAQ.pod t/untaint.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Mon Apr 12 11:04:49 UTC 2010


Author: ansgar-guest
Date: Mon Apr 12 11:04:42 2010
New Revision: 56006

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=56006
Log:
[svn-upgrade] Integrating new upstream version, libwww-mechanize-perl (1.62)

Added:
    branches/upstream/libwww-mechanize-perl/current/t/untaint.t
Modified:
    branches/upstream/libwww-mechanize-perl/current/Changes
    branches/upstream/libwww-mechanize-perl/current/MANIFEST
    branches/upstream/libwww-mechanize-perl/current/META.yml
    branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize.pm
    branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize/Examples.pod
    branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize/FAQ.pod

Modified: branches/upstream/libwww-mechanize-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/Changes?rev=56006&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/Changes (original)
+++ branches/upstream/libwww-mechanize-perl/current/Changes Mon Apr 12 11:04:42 2010
@@ -7,6 +7,28 @@
 
 Mech now has its own mailing list at Google Groups:
 http://groups.google.com/group/www-mechanize-users
+
+NEXT        Sat Apr 10 23:10:07 CDT 2010
+========================================
+[FIXED]
+Fixed a declaration in the Movable Type example in
+WWW::Mechanize::Examples.
+
+Quiet warnings if %ENV has undef values.
+
+$mech->follow_link() no longer dies with an inappropriate error if
+the link is not found.
+
+$mech->click_button() now checks to see if a form is selected.
+
+[INCOMPATIBILITIES]
+$mech->form_name() and $mech->form_number() no longer throw warnings
+if they can't find the form specified.  They still return undef,
+though.
+
+[DOCUMENTATION]
+More additions to the FAQ.
+
 
 1.60        Mon Aug 17 00:41:39 CDT 2009
 ========================================

Modified: branches/upstream/libwww-mechanize-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/MANIFEST?rev=56006&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/MANIFEST (original)
+++ branches/upstream/libwww-mechanize-perl/current/MANIFEST Mon Apr 12 11:04:42 2010
@@ -60,6 +60,7 @@
 t/taint.t
 t/tick.html
 t/tick.t
+t/untaint.t
 t/upload.html
 t/upload.t
 t/warn.t

Modified: branches/upstream/libwww-mechanize-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/META.yml?rev=56006&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/META.yml (original)
+++ branches/upstream/libwww-mechanize-perl/current/META.yml Mon Apr 12 11:04:42 2010
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               WWW-Mechanize
-version:            1.60
+version:            1.62
 abstract:           Handy web browsing in a Perl object
 author:
     - Andy Lester <andy at petdance.com>
@@ -43,7 +43,7 @@
     directory:
         - t
         - inc
-generated_by:       ExtUtils::MakeMaker version 6.52
+generated_by:       ExtUtils::MakeMaker version 6.56
 meta-spec:
     url:      http://module-build.sourceforge.net/META-spec-v1.4.html
     version:  1.4

Modified: branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize.pm?rev=56006&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize.pm (original)
+++ branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize.pm Mon Apr 12 11:04:42 2010
@@ -6,20 +6,46 @@
 
 =head1 VERSION
 
-Version 1.60
-
-=cut
-
-our $VERSION = '1.60';
+Version 1.62
+
+=cut
+
+our $VERSION = '1.62';
 
 =head1 SYNOPSIS
 
-C<WWW::Mechanize>, or Mech for short, helps you automate interaction with
-a website. It supports performing a sequence of page fetches including
-following links and submitting forms. Each fetched page is parsed and
-its links and forms are extracted. A link or a form can be selected, form
-fields can be filled and the next page can be fetched. Mech also stores
-a history of the URLs you've visited, which can be queried and revisited.
+C<WWW::Mechanize>, or Mech for short, is a Perl module for stateful
+programmatic web browsing, used for automating interaction with
+websites.
+
+Features include:
+
+=over 4
+
+=item * All HTTP methods
+
+=item * High-level hyperlink and HTML form support, without having to parse HTML yourself
+
+=item * SSL support
+
+=item * Automatic cookies
+
+=item * Custom HTTP headers
+
+=item * Automatic handling of redirections
+
+=item * Proxies
+
+=item * HTTP authentication
+
+=back
+
+Mech supports performing a sequence of page fetches including
+following links and submitting forms. Each fetched page is parsed
+and its links and forms are extracted. A link or a form can be
+selected, form fields can be filled and the next page can be fetched.
+Mech also stores a history of the URLs you've visited, which can
+be queried and revisited.
 
     use WWW::Mechanize;
     my $mech = WWW::Mechanize->new();
@@ -709,8 +735,14 @@
     }
 
     my $link = $self->find_link(%parms);
-    return $self->get( $link->url ) if $link;
-    $self->die( 'Link not found: ', $link->url ) if $self->{autocheck};
+    if ( $link ) {
+        return $self->get( $link->url );
+    }
+
+    if ( $self->{autocheck} ) {
+        $self->die( 'Link not found' );
+    }
+
     return;
 }
 
@@ -1209,10 +1241,8 @@
         $self->{form} = $self->{forms}->[$form-1];
         return $self->{form};
     }
-    else {
-        $self->warn( "There is no form numbered $form" );
-        return undef;
-    }
+
+    return;
 }
 
 =head2 $mech->form_name( $name )
@@ -1239,10 +1269,8 @@
             if $nmatches > 1;
         return $self->{form} = $matches[0];
     }
-    else {
-        $self->warn( qq{ There is no form named "$form"} );
-        return undef;
-    }
+
+    return;
 }
 
 =head2 $mech->form_id( $name )
@@ -1362,6 +1390,11 @@
 an C<n> key selects an item by number (e.g.
 C<< {n => 3} >> or C<< {n => [2,4]} >>).
 The numbering starts at 1.  This applies to the current form.
+
+If you have a field with C<< <select multiple> >> and you pass a single
+C<$value>, then C<$value> will be added to the list of fields selected,
+without clearing the others.  However, if you pass an array reference,
+then all previously selected values will be cleared.
 
 Returns true on successfully setting the value. On failure, returns
 false and calls C<< $self>warn() >> with an error message.
@@ -1699,7 +1732,8 @@
         $_ = 1 unless defined;
     }
 
-    my $form = $self->{form};
+    my $form = $self->{form} or $self->die( 'click_button: No form has been selected' );
+
     my $request;
     if ( $args{name} ) {
         $request = $form->click( $args{name}, $args{x}, $args{y} );
@@ -2332,7 +2366,7 @@
     return $_taintbrush if _is_tainted( $_taintbrush );
 
     # Let's try again. Maybe somebody cleaned those.
-    $_taintbrush = substr(join("", @ARGV, %ENV), 0, 0);
+    $_taintbrush = substr(join('', grep { defined } @ARGV, %ENV), 0, 0);
     return $_taintbrush if _is_tainted( $_taintbrush );
 
     # If those don't work, go try to open some file from some unsafe
@@ -2869,7 +2903,7 @@
 
 =head1 COPYRIGHT
 
-Copyright (c) 2005-2009 Andy Lester. All rights reserved. This program is
+Copyright (c) 2005-2010 Andy Lester. All rights reserved. This program is
 free software; you can redistribute it and/or modify it under the same
 terms as Perl itself.
 

Modified: branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize/Examples.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize/Examples.pod?rev=56006&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize/Examples.pod (original)
+++ branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize/Examples.pod Mon Apr 12 11:04:42 2010
@@ -489,12 +489,13 @@
 
 =head2 Hacking Movable Type, by Dan Rinzel
 
+    use strict;
     use WWW::Mechanize;
 
     # a tool to automatically post entries to a moveable type weblog, and set arbitary creation dates
 
     my $mech = WWW::Mechanize->new();
-    my %entry;
+    my $entry;
     $entry->{title} = "Test AutoEntry Title";
     $entry->{btext} = "Test AutoEntry Body";
     $entry->{date} = '2002-04-15 14:18:00';

Modified: branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize/FAQ.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize/FAQ.pod?rev=56006&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize/FAQ.pod (original)
+++ branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize/FAQ.pod Mon Apr 12 11:04:42 2010
@@ -233,6 +233,51 @@
     #Access the form using its Zero-Based Index by DOM order
     $mech->form_name('trgForm')->action('http://newAction'); #ABS URL
 
+=head2 How do I save an image?  How do I save a large tarball?
+
+An image is just content.  You get the image and save it.
+
+    $mech->get( 'photo.jpg' );
+    $mech->save_content( '/path/to/my/directory/photo.jpg' );
+
+You can also save any content directly to disk using the C<:content_file>
+flag to C<get()>, which is part of L<LWP::UserAgent>.
+
+    $mech->get( 'http://www.cpan.org/src/stable.tar.gz',
+                ':content_file' => 'stable.tar.gz' );
+
+=head2 How do I pick a specific value from a C<< <select> >> list?
+
+Find the C<HTML::Form::ListInput> in the page.
+
+    my ($listbox) = $mech->find_all_inputs( name => 'listbox' );
+
+Then create a hash for the lookup:
+
+    my %name_lookup;
+    @name_lookup{ $listbox->value_names } = $listbox->possible_values;
+    my $value = $name_lookup{ 'Name I want' };
+
+If you have duplicate names, this method won't work, and you'll
+have to loop over C<< $listbox->value_names >> and
+C<< $listbox->possible_values >> in parallel until you find a
+matching name.
+
+=head2 How do I get Mech to not follow redirects?
+
+You use functionality in LWP::UserAgent, not Mech itself.
+
+    $mech->requests_redirectable( [] );
+
+Or you can set C<max_redirect>:
+
+    $mech->max_redirect( 0 );
+
+Both these options can also be set in the constructor.  Mech doesn't
+understand them, so will pass them through to the LWP::UserAgent
+constructor.
+
+
 =head1 Why doesn't this work: Debugging your Mechanize program
 
 =head2 My Mech program doesn't work, but it works in the browser.

Added: branches/upstream/libwww-mechanize-perl/current/t/untaint.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/t/untaint.t?rev=56006&op=file
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/t/untaint.t (added)
+++ branches/upstream/libwww-mechanize-perl/current/t/untaint.t Mon Apr 12 11:04:42 2010
@@ -1,0 +1,18 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use URI::file;
+
+use Test::More;
+
+eval 'use Test::NoWarnings';
+if ( $@ ) {
+    plan( skip_all => 'Test::NoWarnings not installed' );
+}
+
+plan( tests => 2 ); # the use_ok and then the warning check
+$ENV{test} = 14;
+use_ok( 'WWW::Mechanize' );
+my $uri = URI::file->new_abs( 't/find_link_id.html' )->as_string;
+WWW::Mechanize->new->get($uri);




More information about the Pkg-perl-cvs-commits mailing list