diff --git a/CHANGELOG.md b/CHANGELOG.md index 2de1b83e..53b5148a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -279,4 +279,5 @@ ### Changed - - `add_directory_from_path` and `start_file_from_path` are no longer deprecated. \ No newline at end of file + - `add_directory_from_path` and `start_file_from_path` are no longer deprecated, and they now normalize `..` as well as + `.`. \ No newline at end of file diff --git a/src/write.rs b/src/write.rs index 8a492075..7af5e6f6 100644 --- a/src/write.rs +++ b/src/write.rs @@ -932,8 +932,9 @@ impl ZipWriter { /// Starts a file, taking a Path as argument. /// - /// This function ensures that the '/' path separator is used. It also ignores all non 'Normal' - /// Components, such as a starting '/' or '..' and '.'. + /// This function ensures that the '/' path separator is used and normalizes `.` and `..`. It + /// ignores any `..` or Windows drive letter that would produce a path outside the ZIP file's + /// root. pub fn start_file_from_path>( &mut self, path: P, @@ -1056,12 +1057,9 @@ impl ZipWriter { /// Add a directory entry, taking a Path as argument. /// - /// This function ensures that the '/' path separator is used. It also ignores all non 'Normal' - /// Components, such as a starting '/' or '..' and '.'. - #[deprecated( - since = "0.5.7", - note = "by stripping `..`s from the path, the meaning of paths can change. Use `add_directory` instead." - )] + /// This function ensures that the '/' path separator is used and normalizes `.` and `..`. It + /// ignores any `..` or Windows drive letter that would produce a path outside the ZIP file's + /// root. pub fn add_directory_from_path>( &mut self, path: P, @@ -1123,8 +1121,9 @@ impl ZipWriter { /// Add a symlink entry, taking Paths to the location and target as arguments. /// - /// This function ensures that the '/' path separator is used. It also ignores all non 'Normal' - /// Components, such as a starting '/' or '..' and '.'. + /// This function ensures that the '/' path separator is used and normalizes `.` and `..`. It + /// ignores any `..` or Windows drive letter that would produce a path outside the ZIP file's + /// root. pub fn add_symlink_from_path, T: AsRef, E: FileOptionExtension>( &mut self, path: P,