cnr-isti-vclab / nexus

Nexus is a c++/javascript library for creation and visualization of a batched multiresolution mesh
GNU General Public License v3.0
213 stars 86 forks source link

handle special characters in filenames #168

Open zoltan-mihalyi opened 3 months ago

zoltan-mihalyi commented 3 months ago

Nexus cannot handle file names with special characters.

nxsbuild a.obj # OK
cp a.obj $(echo -n oC5vYmo= | base64 -d) # make a copy with a special filename
nxsbuild $(echo -n oC5vYmo= | base64 -d) # ERROR

Fatal error: could not open file �.obj. Error: No such file or directory

Other programs can open the file

ponchio commented 2 months ago

I think this is a limitation of Qt and how qstring handles content. It seems to work with utf8 encoding but not with invalid encodings. Could not find info on the web about this issue. In order to fix this issue I would have to replace all references to QFile (which takes a QString in input). Is it really needed?

zoltan-mihalyi commented 2 months ago

I was wonderinf it is caused by the .toLatin1() calls in nexus source code.

I develop an application which uses nexus and I can not conrol the filenames of my users, and I haven't found any workaround. If I rename the file, I should also rename the texture and the reference to it, which seems to be a big headache

ponchio commented 2 months ago

Latin1 seems to appear only in the .ply loader due to the fact that the lib requires a char , and it's most probably wrong going back and forward through a qstring. The .obj loader instead convert char to string and uses qfile, , so no toLatin1 calls and with valid utf8 characters it seems to properly work.

So: if the problem is with .obj than most probably the culprit is the encoding, if the problem is with .ply it is my fault (and I will fix it removing the qstring middleman).