mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
Fix unescaped HTML in correct type-in answers (#4407)
* Fix unescaped HTML in correct type-in answers * unit test for correct answer escaping * fix string conversion
This commit is contained in:
parent
23d0657a01
commit
9eb6ec4db8
2 changed files with 11 additions and 1 deletions
|
|
@ -252,6 +252,7 @@ Amanda Sternberg <mandis.sternberg@gmail.com>
|
||||||
arold0 <arold0@icloud.com>
|
arold0 <arold0@icloud.com>
|
||||||
nav1s <nav1s@proton.me>
|
nav1s <nav1s@proton.me>
|
||||||
Ranjit Odedra <ranjitodedra.dev@gmail.com>
|
Ranjit Odedra <ranjitodedra.dev@gmail.com>
|
||||||
|
Eltaurus <https://github.com/Eltaurus-Lt>
|
||||||
|
|
||||||
********************
|
********************
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ trait DiffTrait {
|
||||||
if self.get_typed() == self.get_expected() {
|
if self.get_typed() == self.get_expected() {
|
||||||
format_typeans!(format!(
|
format_typeans!(format!(
|
||||||
"<span class=typeGood>{}</span>",
|
"<span class=typeGood>{}</span>",
|
||||||
self.get_expected_original()
|
htmlescape::encode_minimal(&self.get_expected_original())
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
let output = self.to_tokens();
|
let output = self.to_tokens();
|
||||||
|
|
@ -391,6 +391,15 @@ mod test {
|
||||||
assert_eq!(ctx, "<code id=typeans>123</code>");
|
assert_eq!(ctx, "<code id=typeans>123</code>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn correct_input_is_escaped() {
|
||||||
|
let ctx = Diff::new("source <dir>/bin/activate", "source <dir>/bin/activate");
|
||||||
|
assert_eq!(
|
||||||
|
ctx.to_html(),
|
||||||
|
"<code id=typeans><span class=typeGood>source <dir>/bin/activate</span></code>"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn correct_input_is_collapsed() {
|
fn correct_input_is_collapsed() {
|
||||||
let ctx = Diff::new("123", "123");
|
let ctx = Diff::new("123", "123");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue