From bd3c2355e8e2b220ae5e3cbfe4a057c8088c6a38 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 20 Dec 2011 19:38:19 -0800 Subject: [PATCH] Match usernames in any case in commit message object lists (CC, Reviewers, etc.) Summary: Allow entry of "CC: alincoln" to match user "ALincoln". Put both variations in the map and try the exact case version first since we'll also match email addresses and mailables, and theoretically some mailable might have the same name as a user, as we're effectively abandoning restriction of which characters can appear in usernames. Test Plan: Created a local revision with a reviewer in CrAzY CaPs. Reviewers: jungejason, btrahan Reviewed By: jungejason CC: aran, jungejason Maniphest Tasks: T697 Differential Revision: 1255 --- .../base/DifferentialFieldSpecification.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/applications/differential/field/specification/base/DifferentialFieldSpecification.php b/src/applications/differential/field/specification/base/DifferentialFieldSpecification.php index 65b59dc558..064f1af6ce 100644 --- a/src/applications/differential/field/specification/base/DifferentialFieldSpecification.php +++ b/src/applications/differential/field/specification/base/DifferentialFieldSpecification.php @@ -580,7 +580,15 @@ abstract class DifferentialFieldSpecification { '(username IN (%Ls)) OR (email IN (%Ls))', $value, $value); - $object_map += mpull($users, 'getPHID', 'getUsername'); + $user_map = mpull($users, 'getPHID', 'getUsername'); + foreach ($user_map as $username => $phid) { + // Usernames may have uppercase letters in them. Put both names in the + // map so we can try the original case first, so that username *always* + // works in weird edge cases where some other mailable object collides. + $object_map[$username] = $phid; + $object_map[strtolower($username)] = $phid; + } + $object_map += mpull($users, 'getPHID', 'getEmail'); if ($include_mailables) { @@ -596,7 +604,11 @@ abstract class DifferentialFieldSpecification { $results = array(); foreach ($value as $name) { if (empty($object_map[$name])) { - $invalid[] = $name; + if (empty($object_map[strtolower($name)])) { + $invalid[] = $name; + } else { + $results[] = $object_map[strtolower($name)]; + } } else { $results[] = $object_map[$name]; }