Skip to content

Commit

Permalink
Merge pull request #2378 from tom-tan/trusted-file-readText
Browse files Browse the repository at this point in the history
Mark std.file.readText as trusted
  • Loading branch information
dnadlinger committed Jul 30, 2014
2 parents d52190c + 7aecde3 commit b5a783b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions std/file.d
Expand Up @@ -346,9 +346,10 @@ enforce(chomp(readText("deleteme")) == "abc");
----
*/

S readText(S = string)(in char[] name)
S readText(S = string)(in char[] name) @safe if (isSomeString!S)
{
auto result = cast(S) read(name);
static auto trustedCast(void[] buf) @trusted { return cast(S)buf; }
auto result = trustedCast(read(name));
std.utf.validate(result);
return result;
}
Expand Down

0 comments on commit b5a783b

Please sign in to comment.