Skip to content
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

fix(sourcebundle): Skip non-UTF8 files #2109

Merged
merged 3 commits into from
Jul 23, 2024
Merged

Conversation

loewenheim
Copy link
Contributor

Prompted by #2107 and #2108.

This matches on the error kind returned by SourceBundleWriter::add_file and silently skips ReadFailed errors, which happen on files that aren't valid UTF8. Errors like this are likely caused by asset files that weren't intended to be included in the bundle anyway. It might also make sense to log that we're skipping the file, though.

@loewenheim loewenheim requested review from szokeasaurusrex and Swatinem and removed request for szokeasaurusrex July 23, 2024 09:33
if let Err(e) = bundle.add_file(bundle_path, file.contents.as_slice(), info) {
if e.kind() == SourceBundleErrorKind::ReadFailed {
// This is a non-UTF8 file; it might be an asset which is not intended for inclusion in the
// sourcebundle. We silently skip it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add an info log to inform users that we are skipping the file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally with the file path, something like:

skipping file path/to/file because it is not UTF-8 encoded

@loewenheim loewenheim changed the title fix(sourcebundle): Silently skip non-UTF8 files fix(sourcebundle): Skip non-UTF8 files Jul 23, 2024
Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants