diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 43f7a7e46..01573b419 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -252,6 +252,7 @@ Amanda Sternberg arold0 nav1s Ranjit Odedra +Eltaurus ******************** diff --git a/rslib/src/typeanswer.rs b/rslib/src/typeanswer.rs index 08c638e12..9bf3dc47c 100644 --- a/rslib/src/typeanswer.rs +++ b/rslib/src/typeanswer.rs @@ -58,7 +58,7 @@ trait DiffTrait { if self.get_typed() == self.get_expected() { format_typeans!(format!( "{}", - self.get_expected_original() + htmlescape::encode_minimal(&self.get_expected_original()) )) } else { let output = self.to_tokens(); @@ -391,6 +391,15 @@ mod test { assert_eq!(ctx, "123"); } + #[test] + fn correct_input_is_escaped() { + let ctx = Diff::new("source /bin/activate", "source /bin/activate"); + assert_eq!( + ctx.to_html(), + "source <dir>/bin/activate" + ); + } + #[test] fn correct_input_is_collapsed() { let ctx = Diff::new("123", "123");