Web IDE: Fix encoding issues when uploading
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.
- The changeset d1fb29e5 introduced the usage of
FileReader.readAsDataURL
for both binary and text files. The resulting base64 content is then decoded usingatob
function, which uses ASCII as its default encoding, whereas for Unicode content, UTF-8 should be the default. - 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 |
---|---|
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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
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