emprovements / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

/ vs. \ - suggestion: do not allow \ in directory/file*names* on any platform; always use / internally #359

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The current code has DIRSEP and there's a test file with a path*name* called 
'\' (path ./test/\\/a.txt, where \ is escaped)

Problems with allowing \ in file/dir names:

- it's highly UNIX *and* storage system specific. (I store all source code on a 
network drive set and there '\' is illegal, breaking every hg pull, etc.)

- allowing this character in names only on particular platforms causes 
different behaviour by mongoose where it shouldn't; besides, feeding these kind 
of names (with embedded \ ) to browsers (as they become part of the URL) isn't 
making Windows-based browsers all too happy.

Suggested approach is to use / as dir separator on every platform inside 
mongoose.
Then on platforms which use \ perform a conversion at the latest moment, i.e. 
inside mg_fopen(), opendir/readdir and CGI exec.

Note: windows does understand / too, but with a few caveats: passing absolute 
paths like that to arbitrary CGI applications may have these /x/y/z paths 
parsed as commandline options instead, depending on the CGI executable)

This approach is similar to the way paths are handled in the C++ Boost 
[filesystem] library: this suggestion basically is saying: use 'generic' 
notation throughout mongoose, then use 'native' path notation just before 
invoking system calls that need those.

---

As patch which will fix this will be provided later; this is planned work for 
myself as the / vs. \ **** is making way too much trouble for me.

Original issue reported on code.google.com by ger.hobbelt on 6 Jun 2012 at 12:19

GoogleCodeExporter commented 8 years ago
And another reason: HTML5 File API ( 
http://www.w3.org/TR/html5/number-state.html#file-upload-state )

Original comment by ger.hobbelt on 30 Jun 2012 at 7:07

GoogleCodeExporter commented 8 years ago
Submitted 
https://github.com/valenok/mongoose/commit/167338f2168ccb718c8c85542f4139a1b8198
5fe

Original comment by valenok on 20 Sep 2012 at 5:21