Skip to content

Commit

Permalink
(test) add test to reproduce #422
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed Mar 14, 2021
1 parent fc611e5 commit a8392df
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/escape.rs
Expand Up @@ -3,7 +3,7 @@ extern crate handlebars;
#[macro_use]
extern crate serde_json;

use handlebars::Handlebars;
use handlebars::{handlebars_helper, Handlebars};

#[test]
fn test_escape_216() {
Expand All @@ -19,3 +19,25 @@ fn test_escape_216() {
r"\\\\ foo bar foobar foo#bar foo//bar foo\foo foo\\\foo\\foo \\foo {{FOO}} {{FOO}}"
);
}

#[test]
fn test_string_no_escape_422() {
let mut hbs = Handlebars::new();

handlebars_helper!(replace: |input: str, from: str, to: str| {
input.replace(from, to)
});
hbs.register_helper("replace", Box::new(replace));

assert_eq!(
r#"some\ path"#,
hbs.render_template(r#"{{replace "some/path" "/" "\\ " }}"#, &())
.unwrap()
);

assert_eq!(
r#"some\path"#,
hbs.render_template(r#"{{replace "some/path" "/" "\\" }}"#, &())
.unwrap()
);
}

0 comments on commit a8392df

Please sign in to comment.