-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Dotenv] Fix can not load BOM-signed env files #58216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Unit tests failed, but that's not my fault! |
@@ -9,6 +10,7 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c | |||
|
|||
* 6.4.11 (2024-08-30) | |||
|
|||
* bug #58214 [Dotenv] Fix can not load BOM-signed env files (hosni) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert. This file is generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dotenv files are modeled after sourced shell scripts.
I just tested and neither sh nor bash support parsing dotenv files that start with a BOM.
This means we should not do it.
Instead, we might consider throwing an exception when one is found.
I'd suggest doing it in the doLoad method.
Also, let's use str_starts_with to check for it.
Please submit a new PR if you want to provide the exception I suggested. |
see #58274 for the exception |
…files with BOM (xabbuh) This PR was merged into the 5.4 branch. Discussion ---------- [Dotenv] throw a meaningful exception when parsing dotenv files with BOM | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #58214 | License | MIT This replaces #58216. Other than in that PR I did not account for UTF-16 and UTF-32 byte-order-mark variants as that would IMO require us to first reliably detect the file encoding. Commits ------- b4f3eaa throw a meaningful exception when parsing dotenv files with BOM
In this PR, I fixed the load env file BOM characters.
You can see the full explanation of the issue: #58214
More about BOM: Byte Order Mark