Hashmark in links produces wrong links

Coornail - August 10, 2009 - 11:44
Project:Activity Stream
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

If you write links that has hashmarks in it, the activitystream_twitter_makelinks() produces links that has an tag in an another tag.

The error is in the activitystream_twitter_makelinks() function at the 81th line:

$text = preg_replace('/#(\w*)/', '<a href="http://hashtags.org/tag/\\1/">#\\1</a>', $text);

http://example.com/#lol

will become
<a href="http://example.com/#lol">http://example.com/<a href="http://hashtags.org/tag/#lol>#lol</a></a>

#1

akalsey - November 7, 2009 - 06:04
Version:6.x-1.0-rc2» 6.x-2.x-dev
Status:active» fixed

I think the only proper way to handle this would be to only link a hashtag if it is preceded by whitespace or begins the string. This will mean that if someone were to say #hash#tag without a space separating them then only #hash would get linked and #tag would be ignored. I cant imagine that this is a common case.

Fixed in CVS rev 1.2.2.5.

This fix is going into 2.x only.

#2

System Message - November 21, 2009 - 06:10
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.