diff options
author | Reedy <reedy@wikimedia.org> | 2022-07-16 02:49:14 +0100 |
---|---|---|
committer | Reedy <reedy@wikimedia.org> | 2022-07-16 02:49:14 +0100 |
commit | 32a4629b3d2b61edeaf8a86e83b649d35d3f65f6 (patch) | |
tree | 2ae7c665cdf07167b3aca3f73e6d32eeec7a3cce /includes/htmlform | |
parent | e8cc4c8f9103e0c00a7810f27b0d752c909411f0 (diff) | |
download | mediawikicore-32a4629b3d2b61edeaf8a86e83b649d35d3f65f6.tar.gz mediawikicore-32a4629b3d2b61edeaf8a86e83b649d35d3f65f6.zip |
HtmlForm: Null coalescence in trim() calls
Bug: T312305
Bug: T311572
Bug: T311571
Bug: T311578
Change-Id: I89a135d271c981c011360098ca5e98dc5a47ae37
Diffstat (limited to 'includes/htmlform')
-rw-r--r-- | includes/htmlform/fields/HTMLDateTimeField.php | 2 | ||||
-rw-r--r-- | includes/htmlform/fields/HTMLFloatField.php | 2 | ||||
-rw-r--r-- | includes/htmlform/fields/HTMLIntField.php | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/includes/htmlform/fields/HTMLDateTimeField.php b/includes/htmlform/fields/HTMLDateTimeField.php index ddfcae244cd6..50ae32f1b90a 100644 --- a/includes/htmlform/fields/HTMLDateTimeField.php +++ b/includes/htmlform/fields/HTMLDateTimeField.php @@ -122,7 +122,7 @@ class HTMLDateTimeField extends HTMLTextField { } protected function parseDate( $value ) { - $value = trim( $value ); + $value = trim( $value ?? '' ); if ( $value === '' ) { return false; } diff --git a/includes/htmlform/fields/HTMLFloatField.php b/includes/htmlform/fields/HTMLFloatField.php index 7753b0606c58..0a20afc5e9fe 100644 --- a/includes/htmlform/fields/HTMLFloatField.php +++ b/includes/htmlform/fields/HTMLFloatField.php @@ -17,7 +17,7 @@ class HTMLFloatField extends HTMLTextField { return $p; } - $value = trim( $value ); + $value = trim( $value ?? '' ); # https://www.w3.org/TR/html5/infrastructure.html#floating-point-numbers # with the addition that a leading '+' sign is ok. diff --git a/includes/htmlform/fields/HTMLIntField.php b/includes/htmlform/fields/HTMLIntField.php index 47985043533f..c504d2602d74 100644 --- a/includes/htmlform/fields/HTMLIntField.php +++ b/includes/htmlform/fields/HTMLIntField.php @@ -24,7 +24,7 @@ class HTMLIntField extends HTMLFloatField { # phone numbers when you know that they are integers (the HTML5 type=tel # input does not require its value to be numeric). If you want a tidier # value to, eg, save in the DB, clean it up with intval(). - if ( !preg_match( '/^((\+|\-)?\d+)?$/', trim( $value ) ) ) { + if ( !preg_match( '/^((\+|\-)?\d+)?$/', trim( $value ?? '' ) ) ) { return $this->msg( 'htmlform-int-invalid' ); } |