Skip to content

Commit dbcf063

Browse files
authored
Guard against empty REMOTE_ADDR (#1751)
1 parent 1ea8e3d commit dbcf063

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Integration/RequestIntegration.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private function processEvent(Event $event, Options $options): void
137137
if ($options->shouldSendDefaultPii()) {
138138
$serverParams = $request->getServerParams();
139139

140-
if (isset($serverParams['REMOTE_ADDR'])) {
140+
if (!empty($serverParams['REMOTE_ADDR'])) {
141141
$user = $event->getUser();
142142
$requestData['env']['REMOTE_ADDR'] = $serverParams['REMOTE_ADDR'];
143143

tests/Integration/RequestIntegrationTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,24 @@ public static function invokeDataProvider(): iterable
163163
UserDataBag::createFromUserIpAddress('127.0.0.1'),
164164
];
165165

166+
yield [
167+
[
168+
'send_default_pii' => true,
169+
],
170+
(new ServerRequest('GET', 'http://www.example.com', [], null, '1.1', ['REMOTE_ADDR' => '']))
171+
->withHeader('Host', 'www.example.com'),
172+
[
173+
'url' => 'http://www.example.com',
174+
'method' => 'GET',
175+
'cookies' => [],
176+
'headers' => [
177+
'Host' => ['www.example.com'],
178+
],
179+
],
180+
null,
181+
null,
182+
];
183+
166184
yield [
167185
[
168186
'send_default_pii' => false,

0 commit comments

Comments
 (0)