cyntler / react-doc-viewer

File viewer for React.
https://cyntler.github.io/react-doc-viewer
Apache License 2.0
373 stars 125 forks source link

Proper dataurl charset handling #275

Closed CodeSmith32 closed 3 months ago

CodeSmith32 commented 3 months ago

Currently, when viewing data urls with charsets, the app crashes because the header isn't stripped and base64 decoding (window.atob) throws an error due to invalid base64 chars. This uses a regex for stripping the header with any charset, but also extracts the charset and uses TextDecoder to convert the binary string into a unicode string before being written to the iframe (if necessary).

CodeSmith32 commented 3 months ago

Hey @cyntler,

Anything I can/should do to help this get merged? Or any reason you think it shouldn't be merged?

cyntler commented 3 months ago

@CodeSmith32 I merged it.