diff --git a/src/oauth/PhabricatorMediaWikiAuthProvider.php b/src/oauth/PhabricatorMediaWikiAuthProvider.php index f1eac75..0eab4ad 100644 --- a/src/oauth/PhabricatorMediaWikiAuthProvider.php +++ b/src/oauth/PhabricatorMediaWikiAuthProvider.php @@ -64,7 +64,7 @@ public function getWikiURI() { $normalized .= ':' . $uri->getPort(); } - if ( strlen( ( $uri->getPath() ) ) > 0 && $uri->getPath() !== '/' ) { + if ( $uri->getPath() !== null && $uri->getPath() !== '' && $uri->getPath() !== '/' ) { $normalized .= $uri->getPath(); } @@ -143,7 +143,7 @@ public function processEditForm( $key_secret = self::PROPERTY_CONSUMER_SECRET; $key_consumer = self::PROPERTY_CONSUMER_KEY; - if ( !strlen( $values[$key_uri] ) ) { + if ( $values[$key_uri] === null || $values[$key_uri] === '' ) { $errors[] = pht( 'MediaWiki base URI is required.' ); $issues[$key_uri] = pht( 'Required' ); } else { @@ -157,12 +157,12 @@ public function processEditForm( } } - if ( !$is_setup && !strlen( $values[$key_secret] ) ) { + if ( !$is_setup && ( $values[$key_secret] === null || $values[$key_secret] === '' ) ) { $errors[] = pht( 'Consumer Secret is required' ); $issues[$key_secret] = pht( 'Required' ); } - if ( !$is_setup && !strlen( $values[$key_consumer] ) ) { + if ( !$is_setup && ( $values[$key_consumer] === null || $values[$key_consumer] === '' ) ) { $errors[] = pht( 'Consumer Key is required' ); $issues[$key_consumer] = pht( 'Required' ); } @@ -251,7 +251,7 @@ public function extendEditForm( ); if ( !$is_setup ) { - if ( !strlen( $config->getProperty( self::PROPERTY_CONSUMER_KEY ) ) ) { + if ( $config->getProperty( self::PROPERTY_CONSUMER_KEY ) === null || $config->getProperty( self::PROPERTY_CONSUMER_KEY ) === '' ) { $form->appendRemarkupInstructions( pht( 'NOTE: Copy the keys generated by the MediaWiki OAuth' . diff --git a/src/oauth/PhutilMediaWikiAuthAdapter.php b/src/oauth/PhutilMediaWikiAuthAdapter.php index 6997bce..000cba5 100644 --- a/src/oauth/PhutilMediaWikiAuthAdapter.php +++ b/src/oauth/PhutilMediaWikiAuthAdapter.php @@ -46,7 +46,7 @@ public function getAccountName() { public function getAccountURI() { $name = $this->getAccountName(); - if ( strlen( $name ) ) { + if ( $name !== null && $name !== '' ) { return $this->getWikiPageURI( 'User:' . $name ); } @@ -132,7 +132,7 @@ private function getUserInfo() { // We gen this so we can check for replay below: $nonce = Filesystem::readRandomCharacters( 32 ); - list( $body ) = $this->newOAuth1Future( $uri ) + [ $body ] = $this->newOAuth1Future( $uri ) ->setMethod( 'GET' ) ->setNonce( $nonce ) ->addHeader( 'User-Agent', __CLASS__ ) @@ -205,7 +205,7 @@ private function decodeAndVerifyJWT( $jwt, $nonce ) { /** decode a JWT and verify the signature is valid */ private function decodeJWT( $jwt ) { - list( $headb64, $bodyb64, $sigb64 ) = explode( '.', $jwt ); + [ $headb64, $bodyb64, $sigb64 ] = explode( '.', $jwt ); $header = json_decode( $this->urlsafeB64Decode( $headb64 ) ); $body = json_decode( $this->urlsafeB64Decode( $bodyb64 ) );