Fix #5614: Handle UTF-8 BOM in EPW files#5629
Merged
Merged
Conversation
Strip a leading UTF-8 byte order mark before validating the LOCATION header. Add a regression test covering BOM-prefixed EPW content.\n\nFixes NatLabRockies#5614.
wnykuang
marked this pull request as ready for review
July 11, 2026 21:01
wnykuang
marked this pull request as draft
July 11, 2026 21:04
wnykuang
marked this pull request as ready for review
July 11, 2026 21:06
jmarrec
approved these changes
Jul 13, 2026
|
|
||
| namespace openstudio { | ||
|
|
||
| constexpr std::string_view UTF8_BOM{"\xEF\xBB\xBF", 3}; |
Collaborator
There was a problem hiding this comment.
Ok. Not my prefered style of declaration, but it's valid and defensive (would work with a null byte in the middle too)
Collaborator
|
Ah shoot, since CI is failing due to BCL tests, I didn't notice that Windows x64 was failing the new test. https://github.com/NatLabRockies/OpenStudio/actions/runs/29307997109/job/87338834472#step:23:9224 |
19 tasks
jmarrec
added a commit
that referenced
this pull request
Jul 16, 2026
Hotfix #5629 - read_as_string should open as binary
Contributor
Author
|
@jmarrec thanks for bringing it up, let me try to reproduce and fix it. |
Closed
12 tasks
Collaborator
|
I fixed it in #5633 already |
Contributor
Author
Thanks let me close it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EpwFilecannot process epw file #5614LOCATIONheader.Root cause
EpwFile::parsepassed the first line through unchanged, whileparseLocationrequires the first comma-delimited field to equalLOCATION. For UTF-8-with-BOM files, that field begins with the bytesEF BB BF, so a valid header was reported as missing itsLOCATIONspecifier.The fix only removes a UTF-8 BOM at the beginning of the first line. Existing validation remains unchanged, and this does not attempt to decode UTF-16 or UTF-32 files.
User impact
EPW files saved as UTF-8 with BOM, including the file attached to #5614, can now be processed normally.
Validation
Filetypes.EpwFile_UTF8BOMand observed it fail before the implementation change and pass afterward.Filetypes.EpwFile*tests successfully.EpwFilecannot process epw file #5614 and confirmed the parsing failure no longer occurs.git diff --checksuccessfully.Fixes #5614.