From eae496a72e270fd7af411714738e99a7fadfd19b Mon Sep 17 00:00:00 2001
From: Rickard Green
Date: Wed, 6 Sep 2017 17:00:14 +0200
Subject: Don't allow null in filenames
---
lib/stdlib/doc/src/filename.xml | 78 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 77 insertions(+), 1 deletion(-)
(limited to 'lib/stdlib/doc/src/filename.xml')
diff --git a/lib/stdlib/doc/src/filename.xml b/lib/stdlib/doc/src/filename.xml
index 14fd5ef787..b6028fc066 100644
--- a/lib/stdlib/doc/src/filename.xml
+++ b/lib/stdlib/doc/src/filename.xml
@@ -46,7 +46,10 @@
filename by removing redundant directory separators, use
join/1.
- The module supports raw filenames in the way that if a binary is
+
+ The module supports
+ raw
+ filenames in the way that if a binary is
present, or the filename cannot be interpreted according to the return
value of
file:native_name_encoding/0, a raw filename is also
@@ -56,6 +59,30 @@
(the join operation is performed of course). For more information
about raw filenames, see the
file module.
+
+
+
+ Functionality in this module generally assumes valid input and
+ does not necessarily fail on input that does not use a valid
+ encoding. You can validate the encoding of a filename using
+ filename:validate/1.
+
+
+ File operations used to accept filenames containing
+ null characters (integer value zero). This caused
+ the name to be truncated at the first null character.
+ Filenames containing null characters inside the filename
+ are now rejected and will cause primitive
+ file operations fail.
+
+
+
+ Currently null characters at the end of the filename
+ will be accepted by primitive file operations. Such
+ filenames are however still documented as invalid. The
+ implementation will also change in the future and
+ reject such filenames.
+
@@ -555,6 +582,55 @@ unsafe
["a:/","msdev","include"]
+
+
+
+ Validate encoding of filename
+
+
+ Validates filename encoding. Returns true if
+ FileName has a valid encoding;
+ otherwise, returns false.
+
+
+ Ordinary Filename
+ -
+
+ Type: FileName = file:name()
+
+
+ Validates encoding against the
+ native file
+ name encoding, and the
+ capabilities of the operating system used.
+ Regardless of configuration and OS, null
+ characters (integer value zero) will be
+ rejected by the validation (even when only
+ present at the end of the filename).
+
+
+ Raw
+ Filename
+ -
+
+ Type: FileName = binary()
+
+
+ The encoding will not be interpreted, but
+ null bytes (integer value zero) will be
+ rejected by the validation (even when only
+ present at the end of the filename).
+
+
+
+
+ For information on filename encoding see the documentation
+ of unicode filenames in
+ STDLIB
+ Users Guide ➜ Using Unicode in Erlang ➜ Unicode Filenames.
+
+
+
--
cgit v1.2.3