Fix #5614: Handle UTF-8 BOM in EPW files#5629
Open
wnykuang wants to merge 1 commit into
Open
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.
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)
Comment on lines
+4900
to
+4902
| if ((i == 0) && line.starts_with(UTF8_BOM)) { | ||
| line.erase(0, UTF8_BOM.size()); | ||
| } |
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.