summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2021-12-29 09:16:38 +0100
committerCanop <cano.petrole@gmail.com>2021-12-29 09:16:38 +0100
commit22908e0dfef18e8accf9a2125f8349b448aea2e6 (patch)
tree78207ad713a86cd94fe06742cab71f40d6038a31
parentd296b7139c019e21c542278ea064977073d1af78 (diff)
fix wrong translation from exact pattern to regex patternv1.8.1
Fix: regex pattern automatically built from content pattern when going from a tree search to a file preview isn't escaped Fix #472
-rw-r--r--CHANGELOG.md4
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/pattern/content_pattern.rs2
-rw-r--r--src/pattern/input_pattern.rs4
5 files changed, 9 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e752df4..1098fd7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+### v1.8.1 - 2021-12-29
+<a name="v1.8.1"></a>
+- fix regex pattern automatically built from content pattern when going from a tree search to a file preview isn't escaped - Fix #472
+
<a name="v1.8.0"></a>
### v1.8.0 - 2021-12-26
- alt-i bound to toggle_git_ignore
diff --git a/Cargo.lock b/Cargo.lock
index e8a695b..9bd32e1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -140,7 +140,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "broot"
-version = "1.8.0"
+version = "1.8.1"
dependencies = [
"ahash 0.7.6",
"ansi_colours",
diff --git a/Cargo.toml b/Cargo.toml
index 8fd22a2..d8fef0f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "broot"
-version = "1.8.0"
+version = "1.8.1"
authors = ["dystroy <denys.seguret@gmail.com>"]
repository = "https://github.com/Canop/broot"
documentation = "https://dystroy.org/broot"
diff --git a/src/pattern/content_pattern.rs b/src/pattern/content_pattern.rs
index 3521eec..434e741 100644
--- a/src/pattern/content_pattern.rs
+++ b/src/pattern/content_pattern.rs
@@ -39,7 +39,7 @@ impl ContentExactPattern {
}
pub fn to_regex_parts(&self) -> (String, String) {
- (self.as_str().to_string(), "".to_string())
+ (regex::escape(self.as_str()), "".to_string())
}
pub fn score_of(&self, candidate: Candidate) -> Option<i32> {
diff --git a/src/pattern/input_pattern.rs b/src/pattern/input_pattern.rs
index fa2af5e..d5e6c39 100644
--- a/src/pattern/input_pattern.rs
+++ b/src/pattern/input_pattern.rs
@@ -55,11 +55,11 @@ impl InputPattern {
pub fn tree_to_preview(&self) -> Self {
let regex_parts: Option<(String, String)> = match &self.pattern {
Pattern::ContentExact(cp) => Some(cp.to_regex_parts()),
- Pattern::ContentRegex(cp) => Some(cp.to_regex_parts()),
+ Pattern::ContentRegex(rp) => Some(rp.to_regex_parts()),
Pattern::Composite(cp) => cp.expr
.iter_atoms()
.find_map(|p| match p {
- Pattern::ContentExact(cp) => Some(cp.to_regex_parts()),
+ Pattern::ContentExact(ce) => Some(ce.to_regex_parts()),
Pattern::ContentRegex(cp) => Some(cp.to_regex_parts()),
_ => None
}),