Skip to content

Commit

Permalink
Guard against null phone number value
Browse files Browse the repository at this point in the history
"parsePhoneNumber()" expects a string, so a TypeError would be thrown if
the phone number value is null.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
  • Loading branch information
danxuliu committed Apr 23, 2021
1 parent e2c4a17 commit 7159a70
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/private/Accounts/AccountManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public function updateUser(IUser $user, array $data, bool $throwOnData = false):
$updated = true;

if (isset($data[self::PROPERTY_PHONE]) && $data[self::PROPERTY_PHONE]['value'] !== '') {
// Sanitize null value.
$data[self::PROPERTY_PHONE]['value'] = $data[self::PROPERTY_PHONE]['value'] ?? '';

try {
$data[self::PROPERTY_PHONE]['value'] = $this->parsePhoneNumber($data[self::PROPERTY_PHONE]['value']);
} catch (\InvalidArgumentException $e) {
Expand Down

0 comments on commit 7159a70

Please sign in to comment.