summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/User.pm2
-rw-r--r--Bugzilla/Util.pm24
2 files changed, 24 insertions, 2 deletions
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index 525733069..fafd3551d 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -215,7 +215,7 @@ sub es_document {
},
};
my $name = $self->name;
- my @nicks = defined($name) ? ( $name =~ /:(\w+)\b/mg ) : ();
+ my @nicks = extract_nicks($name);
if (@nicks) {
$doc->{suggest_nick} = {
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index 925db6594..3c4b2fb65 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -26,7 +26,7 @@ use base qw(Exporter);
validate_email_syntax clean_text
get_text template_var disable_utf8
enable_utf8 detect_encoding email_filter
- round);
+ round extract_nicks);
use Bugzilla::Constants;
use Bugzilla::RNG qw(irand);
@@ -883,6 +883,28 @@ sub round {
return (wantarray) ? @res : $res[0];
}
+sub extract_nicks {
+ my ($name) = @_;
+ return () unless defined $name;
+ my @nicks = (
+ $name =~ /
+ # This negative lookbehind lets us
+ # match colons that are not followed by numbers.
+ (?<!\d)
+ :
+ # try tp capture a "word", plus some symbols
+ # this covers most everything people use for ircnicks
+ # in bmo.
+ ([\p{IsAlnum}|._-]+)
+ # require a word terminator, which
+ # can be the end of the string or some punctuation.
+ \b
+ /mgx
+ );
+
+ return grep { defined $_ } @nicks;
+}
+
1;
__END__