Prev | Current Page 472 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

indexOf(???\\??™)+1);
(continued)
Chapter 9: Building Websites with HaXe
245
var path = dir.substr(base.length);
var parts = (~/[\/\\]/g).split(path);
for(part in parts)
{
base += ???/??™ + part;
if(!FileSystem.exists(base))
FileSystem.createDirectory(base);
}
}
private static function removeEmptyDirectories(dir : String, root : String)
{
var d = dir;
while(d != root & & FileSystem.exists(d) & &
FileSystem.readDirectory(d).length == 0)
{
FileSystem.deleteDirectory(d);
d = d.substr(0, d.lastIndexOf(???/??™));
}
}
}
enum RequestAction
{
Edit;
View;
Save(content: String);
}
To maintain the example short some security good practices have been omitted, but be very careful about
malformed URIs. For example, depending on how you handle them, a URI might contain the sequence
%00 which will prevent further appending of an extension, or ../ that will navigate potentially
through the filesystem and outside the public visible web repository. A good way to prevent malicious
intentions is to match the URI correctness using regular expressions that are described in detail in
Chapter 8 .


Pages:
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484