summaryrefslogtreecommitdiff
path: root/rust/libnewsboat/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/libnewsboat/src/utils.rs')
-rw-r--r--rust/libnewsboat/src/utils.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/rust/libnewsboat/src/utils.rs b/rust/libnewsboat/src/utils.rs
index 54328072..5a79d94b 100644
--- a/rust/libnewsboat/src/utils.rs
+++ b/rust/libnewsboat/src/utils.rs
@@ -569,7 +569,7 @@ pub fn strip_comments(line: &str) -> &str {
inside_backticks = !inside_backticks;
}
} else if chr == '#' {
- if !inside_quotes && !inside_backticks {
+ if !prev_was_backslash && !inside_quotes && !inside_backticks {
first_pound_chr_idx = idx;
break;
}
@@ -1126,5 +1126,10 @@ mod tests {
let expected = r#"some `other \` tricky # test` hehe"#;
let input = expected.to_owned() + "#here goescomment";
assert_eq!(strip_comments(&input), expected);
+
+ // Ignores escaped # characters (\\#)
+ let expected = r#"one two \# three four"#;
+ let input = expected.to_owned() + "# and a comment";
+ assert_eq!(strip_comments(&input), expected);
}
}