Erroneously put link to <a> tag following another <a> tag

bostonclimber - December 4, 2008 - 02:26
Project:URL Icon
Version:HEAD
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Thank you for providing this nice tool.

I got a problem and may have a solution to it.

If an <a> tag without 'http://' is followed by another <a> with 'http://', urlicon combines those 2 <a> together and make only one link for them.

For example, the following HTML code has this problem.

<a href="/node/1">Link1</a> foo bar<a href="http://www.example.com">Link2</a>

The output URL Icon generates is

<a href="http://www.example.com">Link2 <img src="/sites/all/modules/urlicon/Icon_External_Link.png"  alt="" title="favicon" class="urlicon urlicon-www_example_com" /></a>

Notice that the Link1 part is missing.

I have a workaround to this problem. I've changed

61:      $reg_exp = '/<a.+?href=\"((http|https|ftp|telnet|news|mms):\/\/.+?)\"[^>]*&gt;(.+?)<\/a>/i';

to
61:      $reg_exp = '/<a[^>]+?href=\"((http|https|ftp|telnet|news|mms):\/\/.+?)\"[^>]*?>(.+?)<\/a>/i';

I don't know this change works for other cases. I don't know how to make a patch either. So, I can't help active development but hope this information helps.

 
 

Drupal is a registered trademark of Dries Buytaert.