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: 19308
Status: rejected
Priority: 0/
Queue: WWW-Mechanize

People
Owner: Nobody in particular
Requestors: MIROD [...] cpan.org
Cc:
AdminCc:

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

Attachments
www-mechanize-test_base_ref.tar.gz



Subject: base_href works only if <head> can be found in the html
The base_href parameter for the content method works by doing $content=~s/<head>/<head>\n<base href="$arg">/; (line 509 of Mechanize.pm v 1.18) You need at least to add the i flag to the regexp, and most likely to be able to cope with cases when there is no head tag. Accounting for cases where the head has attributes is probably slightly overkill (but easy). The fix below replaces line 509, the attached file conatins tests. Note that a real fix would entail using an HTML parser to capture the real head element. if( $content=~ /<head/i) { $content=~ s/(<head[^>]*>)/$1\n<base href="$arg">/i; } elsif( $content=~ /<html/) { $content=~ s/(<html[^>]*>)/$1\n<head><base href="$arg"><\/head>/i; } else { $content= qq{<html><head><base href="$arg"></head>$content</html>}; }
Subject: www-mechanize-test_base_ref.tar.gz

Message body not shown because it is not plain text.