Fix glob problem on Windows.

We weren't actually escaping every use of the file path separator. D'oh.
This commit is contained in:
Andrew Gallant 2016-09-05 21:20:19 -04:00
parent 7f0273c347
commit 3bb387abdd

View File

@ -214,7 +214,7 @@ impl Pattern {
/// regular expression and will represent the matching semantics of this /// regular expression and will represent the matching semantics of this
/// glob pattern and the options given. /// glob pattern and the options given.
pub fn to_regex_with(&self, options: &MatchOptions) -> String { pub fn to_regex_with(&self, options: &MatchOptions) -> String {
let sep = path::MAIN_SEPARATOR.to_string(); let sep = regex::quote(&path::MAIN_SEPARATOR.to_string());
let mut re = String::new(); let mut re = String::new();
re.push_str("(?-u)"); re.push_str("(?-u)");
if options.case_insensitive { if options.case_insensitive {
@ -235,14 +235,14 @@ impl Pattern {
} }
Token::Any => { Token::Any => {
if options.require_literal_separator { if options.require_literal_separator {
re.push_str(&format!("[^{}]", regex::quote(&sep))); re.push_str(&format!("[^{}]", sep));
} else { } else {
re.push_str("."); re.push_str(".");
} }
} }
Token::ZeroOrMore => { Token::ZeroOrMore => {
if options.require_literal_separator { if options.require_literal_separator {
re.push_str(&format!("[^{}]*", regex::quote(&sep))); re.push_str(&format!("[^{}]*", sep));
} else { } else {
re.push_str(".*"); re.push_str(".*");
} }