The twitter_link_filter function works standard for twitter users (prefix = @). And a twitter name can be up to 15 characters. Problem is that if you use this function for hashtags, only hashtags up to 15 characters get a decent link.
Example: #timingiseverything gets a link for #timingiseveryth

How can this be solved? Change the limitation in the regular expression? Of make a separate match-array for usernames and hashtags?

CommentFileSizeAuthor
#2 twitter-821608.patch662 bytesger.lv

Comments

phoenix’s picture

If I change this:

$matches = array(
    '/\>' . $prefix . '([a-z0-9_]{0,15})/i',
    '/^' . $prefix . '([a-z0-9_]{0,15})/i',
    '/(\s+)' . $prefix . '([a-z0-9_]{0,15})/i',
  );

To this:

$matches = array(
    '/\>' . $prefix . '([a-z0-9_]{0,25})/i',
    '/^' . $prefix . '([a-z0-9_]{0,25})/i',
    '/(\s+)' . $prefix . '([a-z0-9_]{0,25})/i',
  );

Then it works! But is this the right way of doing it? And what should be a good number of characters to limit. Now I tried 25, but if the hashtag is longer, we have the same initial problem.

ger.lv’s picture

StatusFileSize
new662 bytes

Changing from '{0,15}' to '{0,25}' is not the best solution.
It's better to change it to '+' - it's going to use the pattern until finds character that's not in the pattern.
And changing it to '+' actually solves the following issue as well #706988.

The patch is attached.

mattgilbert’s picture

Status: Active » Reviewed & tested by the community

This worked for me, thanks!

walkah’s picture

Status: Reviewed & tested by the community » Fixed

I think the only real side effect of this is potentially mis-linking @ references of > 15 characters.

committed for inclusion in the next release.

Status: Fixed » Closed (fixed)

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