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
This commit is contained in:
Nicolas Grekas
2024-09-17 14:51:32 +02:00
3 changed files with 18 additions and 1 deletions

View File

@@ -552,7 +552,13 @@ final class Dotenv
throw new PathException($path);
}
$this->populate($this->parse(file_get_contents($path), $path), $overrideExistingVars);
$data = file_get_contents($path);
if ("\xEF\xBB\xBF" === substr($data, 0, 3)) {
throw new FormatException('Loading files starting with a byte-order-mark (BOM) is not supported.', new FormatExceptionContext($data, $path, 1, 0));
}
$this->populate($this->parse($data, $path), $overrideExistingVars);
}
}

View File

@@ -604,4 +604,14 @@ class DotenvTest extends TestCase
$resetContext();
rmdir($tmpdir);
}
public function testExceptionWithBom()
{
$dotenv = new Dotenv();
$this->expectException(FormatException::class);
$this->expectExceptionMessage('Loading files starting with a byte-order-mark (BOM) is not supported.');
$dotenv->load(__DIR__.'/fixtures/file_with_bom');
}
}

1
Tests/fixtures/file_with_bom vendored Normal file
View File

@@ -0,0 +1 @@
FOO=BAR