Skip to content

Commit 7df47dd

Browse files
authored
chore: add PHP 8.2 to test suite (#476)
1 parent ea7dda7 commit 7df47dd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
php: [ "7.1", "7.2", "7.3", "7.4", "8.0", "8.1"]
13+
php: [ "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2" ]
1414
name: PHP ${{matrix.php }} Unit Test
1515
steps:
1616
- uses: actions/checkout@v2

src/JWT.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ public static function sign(
255255
// The last non-empty line is used as the key.
256256
$lines = array_filter(explode("\n", $key));
257257
$key = base64_decode((string) end($lines));
258+
if (\strlen($key) === 0) {
259+
throw new DomainException('Key cannot be empty string');
260+
}
258261
return sodium_crypto_sign_detached($msg, $key);
259262
} catch (Exception $e) {
260263
throw new DomainException($e->getMessage(), 0, $e);
@@ -312,6 +315,12 @@ private static function verify(
312315
// The last non-empty line is used as the key.
313316
$lines = array_filter(explode("\n", $keyMaterial));
314317
$key = base64_decode((string) end($lines));
318+
if (\strlen($key) === 0) {
319+
throw new DomainException('Key cannot be empty string');
320+
}
321+
if (\strlen($signature) === 0) {
322+
throw new DomainException('Signature cannot be empty string');
323+
}
315324
return sodium_crypto_sign_verify_detached($signature, $msg, $key);
316325
} catch (Exception $e) {
317326
throw new DomainException($e->getMessage(), 0, $e);

0 commit comments

Comments
 (0)