mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2012-06-19 04:06 am

[dw-free] Fix regex for user-tag insertion

[commit: http://hg.dwscoalition.org/dw-free/rev/d019d0f88a75]

Fix regex for user-tag insertion

This regex was broken, it would allow you to do something like "@xb95...."
and try to treat that as a user tag. Now, the regex requires you to do
something that looks like a domain.

This also fixes the case where you refer to someone at the end of a sentence
and it would eat the period.

Patch by [staff profile] mark.

Files modified:
  • cgi-bin/LJ/CleanHTML.pm
--------------------------------------------------------------------------------
diff -r eaca18a897b2 -r d019d0f88a75 cgi-bin/LJ/CleanHTML.pm
--- a/cgi-bin/LJ/CleanHTML.pm	Mon Jun 18 20:49:55 2012 +0800
+++ b/cgi-bin/LJ/CleanHTML.pm	Tue Jun 19 04:11:26 2012 +0000
@@ -1495,7 +1495,7 @@
                 return qq|\@$user.$site|;
             }
         };
-        $$ref =~ s/(?<=\W)\@([\w\d_]+)(?:\.([\w\d\.]+))?(?=$|\W)/$usertag->($1, $2)/mge;
+        $$ref =~ s/(?<=\W)\@([\w\d_]+)((?:\.[\w\d]+)+)?(?=$|\W)/$usertag->($1, $2)/mge;
     }
 
     my $wordlength = defined $opts->{'wordlength'} ? $opts->{'wordlength'} : 40;
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org