Skip to content

Add test cases for non-utf8 paths #11872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/libextra/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,10 @@ impl MatchOptions {
#[cfg(test)]
mod test {
use std::os;
use std::io::fs;
use std::libc::S_IRWXU;

use tempfile;
use super::*;

#[test]
Expand Down Expand Up @@ -572,6 +576,17 @@ mod test {
glob("/*/*/*/*").skip(10000).next();
}

#[test]
#[cfg(not(windows))]
fn test_non_utf8_glob() {
let dir = tempfile::TempDir::new("").unwrap();
let p = dir.path().join(&[0xFFu8]);
fs::mkdir(&p, S_IRWXU as u32);

let pat = p.with_filename("*");
assert_eq!(glob(pat.as_str().expect("tmpdir is not utf-8")).collect::<~[Path]>(), ~[p])
}

#[test]
fn test_range_pattern() {

Expand Down
10 changes: 10 additions & 0 deletions src/libstd/io/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1252,4 +1252,14 @@ mod test {
Err(..) => {}
}
}

#[test]
#[cfg(not(windows))]
fn test_non_utf8_path_exists() {
let p = tmpdir();
// We don't care if it exists or not
// lets just make sure it doesn't break
// with non-UTF-8 paths.
&p.path().join(&[0xFFu8]).exists();
}
}
1 change: 1 addition & 0 deletions src/libstd/path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ fn from_utf8_with_replacement(mut v: &[u8]) -> ~str {
mod tests {
use prelude::*;
use super::{GenericPath, PosixPath, WindowsPath};
use os;
use c_str::ToCStr;

#[test]
Expand Down