Skip to content

Web IDE: Fix encoding issues when uploading

Himanshu Kapoor requested to merge 26113-webide-upload-encoding into master

What does this MR do?

In Web IDE, when you upload a file, sometimes the encoding isn't detected correctly. This change fixes fix it.

  1. The changeset d1fb29e5 introduced the usage of FileReader.readAsDataURL for both binary and text files. The resulting base64 content is then decoded using atob function, which uses ASCII as its default encoding, whereas for Unicode content, UTF-8 should be the default.
  2. Improvements to the download viewer. Files whose mime type cannot be detected will have their file name visible before the download button, and in the name of the downloaded file. Previously, this defaulted to the base64 uri and the file being named download. (See screenshots below.)

This is a partial fix for #26113 (closed)

Screenshots

Before After
Screenshot_2020-01-27_at_4.59.19_PM Screenshot_2020-01-27_at_4.58.27_PM

This MR changes the display name and the downloaded file name for any newly uploaded file that is treated as binary.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Himanshu Kapoor

Merge request reports