[Patch attached]
There's a subtle problem in Test::WWW::Mechanize::Catalyst 0.40, which
unfortunately makes it die in some circumstances.
When HTTP::Response (really HTTP::Headers) has multiple values for the
Content-Type header, the
$response->header('Content-Type')
method returns its values concatenated with a "," (comma) when evaluated
in string context.
Thus the following regex in Test::WWW::Mechanize::Catalyst (line 86):
$response->header('Content-Type') =~ m/charset=(\S+)/xms
captures also an extra comma, making the subsequent statement:
$response->content( Encode::decode( $1, $response->content ) );
die with something like:
Unknown encoding 'utf-8,'
To solve that I suggest to simply use the following regex:
$response->header('Content-Type') =~ m/charset=([^\s,]+)/xms
which should work in any possible situation, since there are no charset
aliases with a comma (according to the IANA Character Sets registry).
(The attached patch uses this solution).
Cheers,
Emanuele Zeppieri.
Subject: | twmc_040_comma_patch |
Message body not shown because it is not plain text.