8000 Merge branch '7.1' into 7.2 · symfony/dotenv@b453abe · GitHub
[go: up one dir, main page]

Skip to content

Commit b453abe

Browse files
Merge branch '7.1' into 7.2
* 7.1: [Process] minor fix [Process] Fix finding executables independently of open_basedir [HttpKernel] Skip logging uncaught exceptions in ErrorHandler, assume $kernel->terminateWithException() will do it [Serializer] Fix for method named `get()` [Notifier][TurboSMS] Process partial accepted response from transport parse empty sequence elements as null [HttpClient] Fix setting CURLMOPT_MAXCONNECTS throw a meaningful exception when parsing dotenv files with BOM [FrameworkBundle] Fix schema & finish incomplete tests for lock & semaphore config [Cache] Fix RedisSentinel params types [FrameworkBundle] Fix service reset between tests [Uid][Serializer][Validator] Mention RFC 9562 make sure temp files can be cleaned up on Windows
2 parents 966f190 + 6d96620 commit b453abe

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Dotenv.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,13 @@ private function doLoad(bool $overrideExistingVars, array $paths): void
552552
throw new PathException($path);
553553
}
554554

555-
$this->populate($this->parse(file_get_contents($path), $path), $overrideExistingVars);
555+
$data = file_get_contents($path);
556+
557+
if ("\xEF\xBB\xBF" === substr($data, 0, 3)) {
558+
throw new FormatException('Loading files starting with a byte-order-mark (BOM) is not supported.', new FormatExceptionContext($data, $path, 1, 0));
559+
}
560+
561+
$this->populate($this->parse($data, $path), $overrideExistingVars);
556562
}
557563
}
558564

Tests/DotenvTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,4 +604,14 @@ public function testBootEnv()
604604
$resetContext();
605605
rmdir($tmpdir);
606606
}
607+
608+
public function testExceptionWithBom()
609+
{
610+
$dotenv = new Dotenv();
611+
612+
$this->expectException(FormatException::class);
613+
$this->expectExceptionMessage('Loading files starting with a byte-order-mark (BOM) is not supported.');
614+
615+
$dotenv->load(__DIR__.'/fixtures/file_with_bom');
616+
}
607617
}

Tests/fixtures/file_with_bom

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FOO=BAR

0 commit comments

Comments
 (0)
0