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: Handle errors caused by presence of charset in blob types #388

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Privat33r-dev
Copy link

@Privat33r-dev Privat33r-dev commented Mar 20, 2024

see commit message

P.S. charset could be extracted with this regex /charset\s*=\s*"?([^()<>@,;:\\\"/[\]?.=\s]*)"?/i

fixes #387

Before the change, a blob type containing a MIME type with the `charset` set
could cause a breaking error. This commit addresses the issue.

It might be an imperfect solution since there might be other charsets, and the
`blob.text()` function always assumes UTF-8. 
However, the alternative would be usage of the `FileReader.readAsText()` which will require additional changes, as the
latter uses callbacks instead of promises, and it might be deprecated later due to this.

The possibility of using another encoding is negligible. Moreover, support for
it might be introduced later in case someone reports a problem.
@Privat33r-dev
Copy link
Author

@LunaticMuch @IvanGoncharov I would appreciate if you can find a few minutes to review the PR.

@Privat33r-dev
Copy link
Author

@LunaticMuch @IvanGoncharov it would be amazing if you can find a couple of minutes to review this PR :) We are trying to clear a backlog in our tool and we have an issue that is likely caused by the problem that this PR fixes.

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.

White screen with error in console: Can not convert data url with MIME type:text/plain;charset=utf8
1 participant