WWW::Mechanize is a wonderful tool. However, there are all sorts of little things that I like to add that extend beyond what it's intended to do. Some of these issues are "Perl only" (such as Detecting stringified references with WWW::Mechanize), and others are more generic, such as detecting when an HTML entity has been encoded twice (e.g., & -- we had methods that shouldn't be encoding their output, but they did and then they got encoded again in Mason).
To deal with the double-encoding problem, I added a very simple line to my overloaded content() method (see above link):
if ($content =~ /(&(?:[lg]t|amp|quot);)/) { carp "Possible double-encoded HTML entity ($1) found in result +s"; }
However, I can think of several other potential issues I would like to check and make warnings for them optional by instantiating my subclass with a hashref and suppressing warnings that I don't want (maybe a page is trying to display HTML entity codes and wants them double-encoded):
my $mech = WWW::Mechanize::Warnings->new( stringified_references => 1, valid_dtd => 1, encoded_entities => 0, valid_html => 1, );
I think the warnings should be on by default, so only the "encoded_entities" key/value pair would be strictly necessary in the hypothetical constructor above.
What else would you want to see in such a module? If it's anything tricky, implementation ideas would be welcome.
Cheers,
Ovid
New address of my CGI Course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Customizing WWW::Mechanize
by jonadab (Parson) on Jan 13, 2004 at 02:01 UTC | |
|
Re: Customizing WWW::Mechanize
by clscott (Friar) on Jan 13, 2004 at 03:26 UTC | |
|
Re: Customizing WWW::Mechanize
by revdiablo (Prior) on Jan 13, 2004 at 06:23 UTC | |
|
Re: Customizing WWW::Mechanize
by ViceRaid (Chaplain) on Jan 13, 2004 at 17:49 UTC |