Skip Menu |

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

Report information
The Basics
Id: 43441
Status: open
Worked: 40 min
Priority: 0/
Queue: HTML-Mail

People
Owner: plank [...] cpan.org
Requestors: calvin_x_cheng [...] yahoo.com
Cc:
AdminCc:

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



Subject: Problem with HTML::Mail named anchor
Date: Thu, 19 Feb 2009 10:23:21 -0800 (PST)
To: bug-HTML-Mail [...] rt.cpan.org
From: Calvin Cheng <calvin_x_cheng [...] yahoo.com>
Hello, I am trying to send an HTML email with named anchor inside. For example, I have the following, <a href="#section1">Go to section 1</a> and later <a name="section1">This is section 1</a> in a HTML file demo.html inside a directory /x/y When I sent this file using HTML::Mail, the first link is changed to <a href="file:///x/y/demo.html#section1"> which is obviously incorrect since the recipient does not have a file demo.html on his local drive. This link should not be changed at all. How do I solve this problem? Is this a bug in the HTML::Mail module? Best regards, Calvin Cheng
It's most likely a bug. I'll have a look and try to fix it. Thank you for your report.
On Wed Mar 04 16:51:37 2009, PLANK wrote: Show quoted text
> It's most likely a bug.
It's definitely a bug and should be fixed with caution. I'll also have to try to check whether email clients cope with internal named anchors properly.
I've attached a very simple patch that seems to address this. I can supply a test if required (although it would simply be examining the output to confirm the anchor is intact). I've tested an HTML email with anchors in 2 different clients and they appear to work (but YMMV). It certainly didn't break anything.
--- lib/HTML/Mail.pm 2008-08-10 02:25:35.000000000 +1000 +++ lib/HTML/Mail.pm.anchors 2009-12-17 15:29:51.000000000 +1100 @@ -330,7 +330,9 @@ $self->_tag_filter_link($attr, 'href'); } }elsif($tag eq 'a' and defined($attr->{'href'})){ - $attr->{'href'} = $self->_create_uri($attr->{'href'}); + unless ($attr->{'href'} =~ /^\#/) { + $attr->{'href'} = $self->_create_uri($attr->{'href'}); + } } $self->_tag_filter_link($attr, 'background'); $self->_tag_filter_link($attr, 'src') if ($tag ne 'script');