Skip Menu |

This queue is for tickets about the MIME-Lite-HTML CPAN distribution.

Report information
The Basics
Id: 19656
Status: resolved
Priority: 0/
Queue: MIME-Lite-HTML

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

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



Subject: unknown URI schemes cause rewrite to fail
When rewriting content in the &parse routine, the creation of new URI::WithBase objects should be eval-wrapped. Otherwise, MIME::Lite::HTML will fail when the HTML contains an href to a scheme that URI doesn't now about -- like javascript. In other words, this line: my $urlAbs = URI::WithBase->new($$url[2],$racinePage)->abs; should read: my $urlAbs = eval { URI::WithBase->new($$url[2],$racinePage)->abs; }; -- rjbs
This bug is nearly two months old. Is this distribution abandoned? -- rjbs
I sent the author another email about this. -- rjbs
Show quoted text
> In other words, this line: > > my $urlAbs = URI::WithBase->new($$url[2],$racinePage)->abs; > > should read: > > my $urlAbs = eval { URI::WithBase->new($$url[2],$racinePage)->abs; };
Have you an example ? I try with: <img src="jjavascript:alert('http://alianwebserver.alianet');"> or <img src="javascript:alert('http://alianwebserver.alianet');"> or <a href="jjavascript:alert('http://alianwebserver.alianet');"> or <a href="javascript:alert('http://alianwebserver.alianet');"> withtout problem
Wow! Reproducing this was a /lot/ harder than I thought! Fortunately, I still had the stack trace of this problem in our internal bug system. The issue is that: 1. unknown URI schemes lead to URI::_foreign objects 2. URI::URL extends URI::_foreign 3. these extensions cause it to die on unknown scheme /IF/ strict is set 4. strict is a global variable 5. something else somewhere is setting it Since I probably can't always control what will touch that global variable, the solution is either to: a. save old value of strict before rewriting, then restore b. eval the creation of the WithBase Since WithBase will never (I think!) end up being useful for _foreign URIs, I think that eval is simpler and more straightforward. -- rjbs
The attached script demonstrates this bug. -- rjbs
#!perl use strict; use warnings; use MIME::Lite::HTML; # This could be done by nearly anything anywhere in some other module: { require URI::URL; URI::URL->strict(1); } my $ml = MIME::Lite::HTML->new( IncludeType => 'extern', From => 'rjbs@rjbs.rjbs', To => 'rjbs@rjbs.rjbs', Subject => 'rjbs@rjbs.rjbs', ); my $html = <<'END_HTML'; <html> <body> Yourface. <a href="xxx://yourface">foo</a> <img src="xxx://yourface" /> </body> </html> END_HTML my $mlmail = $ml->parse( $html, "" );
After a LOT of grepping, I believe the culprit in my program was URI::Find. See its changelog: http://search.cpan.org/src/ROSCH/URI-Find-0.16/Changes They fixed this bug, but anyone else can re-introduce it, because it is global. Defensive programming suggests we assume that strict is on. -- rjbs
On Wed Sep 06 09:39:30 2006, RJBS wrote: Show quoted text
> The attached script demonstrates this bug.
Ok with that, I understand and make the correct fix & add tests for that.