From 489897a6a78c41781ac5a5b1db222896cc90b33d Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 27 Jul 2017 16:45:14 -0700 Subject: Bug 1378873 - user autocomplete no longer works for some strings --- Bugzilla/User.pm | 2 +- Bugzilla/Util.pm | 24 +++++++++++++++++++- t/extract-nicks.t | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 t/extract-nicks.t 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. + (?) { + my @nicks = extract_nicks($_); + is_deeply(\@nicks, shift @expect); +} + +done_testing; + +__DATA__ +Dhanesh Sabane [:dhanesh95] (UTC+5:30) +Anthony Jones (:kentuckyfriedtakahe, :k17e) +Emma Humphries' Possibly Evil Twin (don't assign me bugs or needinfo, send those to :emceeaich, I'm just here for testing bmo) +Sebastin Santy [:seban] +Emma Humphries ☕️ (she/her) [:emceeaich] (UTC-8) +needinfo me +Byron Jones ‹:glob› +Brian Smith (:briansmith, :bsmith, use NEEDINFO?) +Boris Zbarsky [:bz] +Dave Lawrence (not real account) [:dkl-test] +Dylan Hardison [:dylan] (he/him) +[:7] +Blake Winton (:bwinton) (:☕️) +Jeff Griffiths (:canuckistani) (:⚡︎) +GaryChen [:GaryChen][:PYChen][:gchen][:陳柏宇] +Mozilla Graphics [:gfx] [:#gfx] +Ted Mielczarek [:ted.mielczarek] +Michiel van Leeuwen (email: mvl+moz@) +Thunderbird Localization Community [:tb-l10n] +:Gavin Sharp [email: censored@censored.com] +Ошибка монстра (:прозвище) -- cgit v1.2.3-24-g4f1b