[imp] Bug with URLs of form <http://www.aol.com>

Jeff Tucker jeff at jltnet.com
Wed Dec 10 20:13:45 PST 2003


--On Wednesday, December 10, 2003 6:04 PM -0500 Chuck Hagenbuch 
<chuck at horde.org> wrote:

> Quoting Jeff Tucker <jeff at jltnet.com>:
>
>> In Horde CVS HEAD from a couple days ago, there is a bug in URLs which
>> include angle brackets. The application will detect and properly format
>> URLs like http://www.aol.com. If, however, you write the URL
>> <http://www.aol.com> the application leaves off the initial "h" and tries
>> to redirect to ttp://www.aol.com which obviously doesn't work.
>>
>> I'll try to track this down later today, but if someone knows right where
>> to look, that would be nice.
>
> Look in horde/lib/Text.php in the linkUrls() function. I'd do it myself,
> but don't have time to debug it right now.
>

Chuck,

I don't know diddly about regexp's, but I can see where the problem is.

You have preg_match_all('~(((^|[^<])?(\w+))://....
The interesting part is (^|[^<]) which ends up being $match[3] later down 
the road. If the URL starts with a space, $match[3] is that space and 
$match[4] is the word characters which appears in the next subpattern (i.e. 
"http"). If the URL starts with a <, though, the < can't match that 
interesting part. That means that the "h" matches the interesting part and 
$match[3] becomes "h" while $match[4] is "ttp".

Back in version 1.91, you had preg_match_all('~(((^|\s)?(\w+))://....
This works for the cases I've seen. I'm not exactly sure what you mean by 
the comment you put in the log for version 1.92. You said you don't want to 
match a link <foo> but I think you need to.

Jeff



More information about the imp mailing list