Make the file reader utility aware of BOMs #1045
Merged
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.
Fixes #1042
Made the CLI file reader utility aware of the BOM, and skip it. The code was copied from https://github.com/dimchansky/utfbom.
It might be an option to move this to the https://github.com/smallstep/cli-utils repo and implement this in the
fileutil
package.In addition to the BOM, this PR also improves the error messages returned a bit by escaping the file name, and prevents index out of range errors when no PEM blocks are detected in a file.