From e80d7244bc8001f3a0f9fdbff1b01f229f8fbdb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Thu, 19 Jan 2017 00:33:52 +0100 Subject: [PATCH] Add PathEntry.validateFilename. --- source/vibe/core/path.d | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/vibe/core/path.d b/source/vibe/core/path.d index 12d4f49..a326308 100644 --- a/source/vibe/core/path.d +++ b/source/vibe/core/path.d @@ -446,6 +446,13 @@ unittest struct PathEntry { import std.string : cmp; + static PathEntry validateFilename(string fname) + @safe { + import std.string : indexOfAny; + enforce(fname.indexOfAny("/\\") < 0, "File name contains forward or backward slashes: "~fname); + return PathEntry(fname, PathType.inet); + } + @safe pure nothrow: private {