chorton2227 / maplelib2

Automatically exported from code.google.com/p/maplelib2
0 stars 0 forks source link

Export doesn't sanitise file paths #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Export any WZ that has invalid characters in the data path.

Example:
Map.wz/Obj/etc.img/coconut/frontTime/:
Will produce:
coconut.fontTime.:.png
Which is not a valid file name.

What is the expected output? What do you see instead?
Output cannot be saved to the disk without changing it, so nothing is expected.

What version of the product are you using? On what operating system?
Revision 22
Microsoft Visual Studio 2010 Ultimate
Windows 7 64-bit

Please provide any additional information below.
Quick-fix in WzSerializer.cs for those interested:
string invalid = new string(Path.GetInvalidFileNameChars());
foreach (char c in invalid) currObj.Name = currObj.Name.Replace(c.ToString(), 
"_");

This will replace all invalid file name characters with an underscore. A 
problem will occur if there is Foo.Bar.:.png and Foo.Bar.|.png, as one will 
overwrite the other. Perhaps replacing the character with the dec/hex value 
would work better.

Original issue reported on code.google.com by shifu.ma...@gmail.com on 8 May 2012 at 12:18