import expression with paths

Lemonfiend lemon at fie.nd
Thu Jan 30 07:58:54 PST 2014


This does not compile on Windows, but does compile on Mac:

---
module main;

void main()
{
	import std.path;
	enum bar = import(`dir` ~ dirSeparator ~ `bar.txt`);
}
---

The docs say:
http://dlang.org/expression.html#ImportExpression
"Implementations may restrict the file name in order to avoid 
directory traversal security vulnerabilities. A possible 
restriction might be to disallow any path components in the file 
name."

So, I suppose it's valid code. But it's still surprising to 
encounter.
Should it not simply be disallowed completely?


More information about the Digitalmars-d-learn mailing list