Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Mechanize CPAN distribution.

Report information
The Basics
Id: 25215
Status: resolved
Priority: 0/
Queue: WWW-Mechanize

People
Owner: Nobody in particular
Requestors: stpierre [...] NebrWesleyan.edu
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Can't find forms based on fields of the format 'a[b]'
Date: Wed, 28 Feb 2007 08:43:33 -0600 (CST)
To: bug-WWW-Mechanize [...] rt.cpan.org
From: "Chris St. Pierre" <stpierre [...] NebrWesleyan.edu>
When given a field name of the format 'a[b]', WWW::Mechanize refuses to find the form with the listed fields with form_with_fields() or the with_fields parameter of submit_form(). If you select the form by number (or my other means), though, the field() sub works fine. In the attached files, the first test in mechtest.pl fails, but the second succeeds. Chris St. Pierre Unix Systems Administrator Nebraska Wesleyan University

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #25215] AutoReply: Can't find forms based on fields of the format 'a[b]'
Date: Wed, 28 Feb 2007 09:18:21 -0600 (CST)
To: Bugs in WWW-Mechanize via RT <bug-WWW-Mechanize [...] rt.cpan.org>
From: "Chris St. Pierre" <stpierre [...] NebrWesleyan.edu>
There are two possible solutions to this. One involves using quotemeta() to ensure that metacharacters in the field name are not interpreted by the regex: --- /usr/lib/perl5/vendor_perl/5.8.5/WWW/Mechanize.pm 2006-08-19 01:07:57.000000000 -0500 +++ Mechanize.pm 2007-02-28 08:51:34.000000000 -0600 @@ -1059,7 +1059,8 @@ my @matches; FORMS: for my $form (@{ $self->forms }) { my @fields_in_form = $form->param(); - for my $field (@fields) { + my @rectified_fields = quotemeta(@fields); + for my $field (@rectified_fields) { next FORMS unless grep { m/^$field$/ } @fields_in_form; } push @matches, $form; The other involves removing the regex: -- /usr/lib/perl5/vendor_perl/5.8.5/WWW/Mechanize.pm 2006-08-19 01:07:57.000000000 -0500 +++ Mechanize.pm 2007-02-28 09:14:50.000000000 -0600 @@ -1060,7 +1060,7 @@ FORMS: for my $form (@{ $self->forms }) { my @fields_in_form = $form->param(); for my $field (@fields) { - next FORMS unless grep { m/^$field$/ } @fields_in_form; + next FORMS unless grep { $_ eq $field } @fields_in_form; } push @matches, $form; } Since the regex was matching a full string, anchored on both ends, case-sensitive, replacing it with the 'eq' operator is, IMHO, The Right Thing to do. Chris St. Pierre Unix Systems Administrator Nebraska Wesleyan University
Thanks. This has been resolved in 1.22.