Просмотр исходного кода

Only match emails if it begins at the beginning of a line or after something other than ':' URL on that line. Fixes BugID#618540

sbingner 23 лет назад
Родитель
Сommit
93d67fe549
3 измененных файлов с 7 добавлено и 5 удалено
  1. 2 0
      docs/Changelog
  2. 1 1
      modules/Pisg/Common.pm
  3. 4 4
      modules/Pisg/HTMLGenerator.pm

+ 2 - 0
docs/Changelog

@@ -10,6 +10,8 @@ pisg (x.xx)
      in the line fall back to using word following attack word
    * Chop lines added to sayings to the length of maxquote (so we don't have
      super long quotes showing up - BugID#594618)
+   * Only match emails if it begins at the beginning of a line or after
+     something other than ':' URL on that line. Fixes BugID#618540
 
 
 

+ 1 - 1
modules/Pisg/Common.pm

@@ -149,7 +149,7 @@ sub match_urls
     $str =~ s/(http:\/\/)?www\./http:\/\/www\./igo;
 
     my @urls;
-    while ($str =~ s/(http|https|ftp|telnet|news)(:\/\/[-a-zA-Z0-9_\/~]+\.[-a-zA-Z0-9.,_~=:&@%?#\/+]+)//io) { 
+    while ($str =~ s/(http|https|ftp|telnet|news)(:\/\/[-a-zA-Z0-9_\/~@:]+\.[-a-zA-Z0-9.,_~=:&@%?#\/+]+)//io) { 
         my $url = "$1$2";
         if ($url_seen{$url}) {
             push(@urls, $url);

+ 4 - 4
modules/Pisg/HTMLGenerator.pm

@@ -1784,11 +1784,11 @@ sub _replace_links
     my $textmail = $self->_template_text("mailto");
 
     if ($nick) {
-        $str =~ s/(http|https|ftp|telnet|news)(:\/\/[-a-zA-Z0-9_\/~]+\.[-a-zA-Z0-9.,_~=:&amp;@%?#\/+]+)/<a href="$1$2" target="_blank" title="$texturl $1$2">$nick<\/a>/g;
-        $str =~ s/([-a-zA-Z0-9._]+@[-a-zA-Z0-9_]+\.[-a-zA-Z0-9._]+)/<a href="mailto:$1" title="$textmail $nick">$nick<\/a>/g;
+        $str =~ s/(http|https|ftp|telnet|news)(:\/\/[-a-zA-Z0-9_\/~:@]+\.[-a-zA-Z0-9.,_~=:&amp;@%?#\/+]+)/<a href="$1$2" target="_blank" title="$texturl $1$2">$nick<\/a>/g;
+        $str =~ s/(^|[^:])\b([-a-zA-Z0-9._]+@[-a-zA-Z0-9_]+\.[-a-zA-Z0-9._]+)/$1<a href="mailto:$2" title="$textmail $nick">$nick<\/a>/g;
     } else {
-        $str =~ s/(http|https|ftp|telnet|news)(:\/\/[-a-zA-Z0-9_\/~]+\.[-a-zA-Z0-9.,_~=:&amp;@%?#\/+]+)/<a href="$1$2" target="_blank" title="$texturl $1$2">$1$2<\/a>/g;
-        $str =~ s/([-a-zA-Z0-9._]+@[-a-zA-Z0-9_]+\.[-a-zA-Z0-9._]+)/<a href="mailto:$1" title="$textmail $1">$1<\/a>/g;
+        $str =~ s/(http|https|ftp|telnet|news)(:\/\/[-a-zA-Z0-9_\/~:@]+\.[-a-zA-Z0-9.,_~=:&amp;@%?#\/+]+)/<a href="$1$2" target="_blank" title="$texturl $1$2">$1$2<\/a>/g;
+        $str =~ s/(^|[^:])\b([-a-zA-Z0-9._]+@[-a-zA-Z0-9_]+\.[-a-zA-Z0-9._]+)/$1<a href="mailto:$2" title="$textmail $2">$2<\/a>/g;
     }
     return $str;
 }