This commit is contained in:
Maurício Meneghini Fauth 2026-06-02 23:44:13 +01:00 committed by GitHub
commit ee962cb68b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 71 additions and 24 deletions

View File

@ -16,6 +16,10 @@ use PragmaRX\Google2FAQRCode\Google2FA;
use function __;
use function extension_loaded;
use function restore_error_handler;
use function set_error_handler;
use const E_DEPRECATED;
/**
* HOTP and TOTP based two-factor authentication
@ -89,11 +93,20 @@ class Application extends TwoFactorPlugin
public function setup()
{
$secret = $this->twofactor->config['settings']['secret'];
$inlineUrl = $this->google2fa->getQRCodeInline(
'phpMyAdmin (' . $this->getAppId(false) . ')',
$this->twofactor->user,
$secret
);
// Suppress PHP 8.4 deprecation from third-party package
set_error_handler(static function (int $level): bool {
return $level === E_DEPRECATED;
});
try {
$inlineUrl = $this->google2fa->getQRCodeInline(
'phpMyAdmin (' . $this->getAppId(false) . ')',
$this->twofactor->user,
$secret
);
} finally {
restore_error_handler();
}
return $this->template->render('login/twofactor/application_configure', [
'image' => $inlineUrl,

View File

@ -65,8 +65,10 @@ use function preg_replace;
use function random_bytes;
use function range;
use function reset;
use function restore_error_handler;
use function round;
use function rtrim;
use function set_error_handler;
use function set_time_limit;
use function sort;
use function sprintf;
@ -85,6 +87,7 @@ use function time;
use function trim;
use function uksort;
use const E_DEPRECATED;
use const ENT_COMPAT;
use const ENT_QUOTES;
use const PHP_INT_SIZE;
@ -716,14 +719,12 @@ class Util
$date = (string) preg_replace(
'@%[aA]@',
// phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated
$dayOfWeek[(int) @strftime('%w', (int) $timestamp)],
$dayOfWeek[(int) self::strftime('%w', (int) $timestamp)],
$format
);
$date = (string) preg_replace(
'@%[bB]@',
// phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated
$month[(int) @strftime('%m', (int) $timestamp) - 1],
$month[(int) self::strftime('%m', (int) $timestamp) - 1],
$date
);
@ -739,8 +740,7 @@ class Util
// Can return false on windows for Japanese language
// See https://github.com/phpmyadmin/phpmyadmin/issues/15830
// phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated
$ret = @strftime($date, (int) $timestamp);
$ret = self::strftime($date, (int) $timestamp);
// Some OSes such as Win8.1 Traditional Chinese version did not produce UTF-8
// output here. See https://github.com/phpmyadmin/phpmyadmin/issues/10598
if ($ret === false || mb_detect_encoding($ret, 'UTF-8', true) !== 'UTF-8') {
@ -750,6 +750,20 @@ class Util
return $ret;
}
/** @return string|false */
private static function strftime(string $format, ?int $timestamp = null)
{
set_error_handler(static function (int $level): bool {
return $level === E_DEPRECATED;
});
try {
// phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated
return $timestamp === null ? strftime($format) : strftime($format, $timestamp);
} finally {
restore_error_handler();
}
}
/**
* Splits a URL string by parameter
*
@ -1714,8 +1728,7 @@ class Util
}
/* Do the replacement */
// phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated
return strtr((string) @strftime($string), $replace);
return strtr((string) self::strftime($string), $replace);
}
/**

View File

@ -21,9 +21,12 @@ use Webmozart\Assert\Assert;
use function array_map;
use function base64_encode;
use function json_decode;
use function restore_error_handler;
use function set_error_handler;
use function sodium_base642bin;
use function sodium_bin2base64;
use const E_DEPRECATED;
use const SODIUM_BASE64_VARIANT_ORIGINAL;
use const SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING;
@ -142,12 +145,21 @@ final class WebauthnLibServer implements Server
'timeout' => 60000,
]);
Assert::isInstanceOf($requestOptions, PublicKeyCredentialRequestOptions::class);
$server->loadAndCheckAssertionResponse(
$assertionResponseJson,
$requestOptions,
$userEntity,
$request
);
// Suppress PHP 8.1 deprecation from third-party package
set_error_handler(static function (int $level): bool {
return $level === E_DEPRECATED;
});
try {
$server->loadAndCheckAssertionResponse(
$assertionResponseJson,
$requestOptions,
$userEntity,
$request
);
} finally {
restore_error_handler();
}
}
public function parseAndValidateAttestationResponse(
@ -191,11 +203,20 @@ final class WebauthnLibServer implements Server
];
$credentialCreationOptions = PublicKeyCredentialCreationOptions::createFromArray($creationOptionsArray);
Assert::isInstanceOf($credentialCreationOptions, PublicKeyCredentialCreationOptions::class);
$publicKeyCredentialSource = $server->loadAndCheckAttestationResponse(
$attestationResponse,
$credentialCreationOptions,
$request
);
// Suppress PHP 8.1 deprecation from third-party package
set_error_handler(static function (int $level): bool {
return $level === E_DEPRECATED;
});
try {
$publicKeyCredentialSource = $server->loadAndCheckAttestationResponse(
$attestationResponse,
$credentialCreationOptions,
$request
);
} finally {
restore_error_handler();
}
return $publicKeyCredentialSource->jsonSerialize();
}