Skip to content

Commit e7d8e15

Browse files
committed
getSessionId to return null on empty session id, avoiding strtr() warnings
1 parent 93b4b58 commit e7d8e15

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎src/SensitiveValueSanitizer.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private function getSessionId(): ?string
4949
} else {
5050
$sessionId = $_COOKIE[$sessionName] ?? null;
5151
}
52-
return is_string($sessionId) ? $sessionId : null;
52+
return is_string($sessionId) && $sessionId !== '' ? $sessionId : null;
5353
}
5454

5555

‎tests/PhpInfoTest.phpt‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,18 @@ class PhpInfoTest extends TestCase
135135
Assert::contains('🍕', $html);
136136
}
137137

138+
139+
public function testGetHtmlEmptySessionCookie(): void
140+
{
141+
session_write_close();
142+
$_SERVER['HTTP_COOKIE'] = 'PHPSESSID=';
143+
$_COOKIE['PHPSESSID'] = '';
144+
session_start();
145+
Assert::noError(function (): void {
146+
(new PhpInfo())->getHtml();
147+
});
148+
}
149+
138150
}
139151

140152
(new PhpInfoTest())->run();

0 commit comments

Comments
 (0)