cockpit-project / cockpit-files

A Featureful File Browser for Cockpit (Modernized and tested version of https://github.com/45Drives/cockpit-navigator)
GNU Lesser General Public License v2.1
27 stars 23 forks source link

Properly handle non-latin1 filename in downloads #604

Closed leomoty closed 2 weeks ago

leomoty commented 2 weeks ago

So as described in #602, it isnt able to properly encode non-latin1 characters and btoa fails to encode it.

TextEncoder nets you the underlying utf8 bytes, which btoa is also not able to handle directly. But I did take @allisonkarlitskaya suggestion and didnt rely on cockpit.base64_encode, instead just apply every byte as its own character to btoa.

I have added a test, but I have tried to use the tasks container to run it, but I keep getting failures that I cant figure out. I think it is environmental issue, and has nothing to do with the test harness itself.