This commit is contained in:
Elias 2025-09-16 05:34:46 +00:00 committed by GitHub
commit 8421a34dcb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 4 deletions

View file

@ -242,6 +242,7 @@ Lee Doughty <32392044+leedoughty@users.noreply.github.com>
memchr <memchr@proton.me> memchr <memchr@proton.me>
Max Romanowski <maxr777@proton.me> Max Romanowski <maxr777@proton.me>
Aldlss <ayaldlss@gmail.com> Aldlss <ayaldlss@gmail.com>
Elias Johansson Lara <elias.johanssonlara@gmail.com>
******************** ********************

View file

@ -309,3 +309,12 @@ def test_findDupes():
assert not r assert not r
# front isn't dupe # front isn't dupe
assert col.find_dupes("Front") == [] assert col.find_dupes("Front") == []
def test_find_cards_with_newlines():
col = getEmptyCol()
note = col.newNote()
note["Front"] = "foo"
note["Back"] = "foo<br>bar"
col.addNote(note)
assert len(col.find_cards("foo\nbar")) == 1

View file

@ -221,7 +221,7 @@ fn group_inner(input: &str) -> IResult<'_, Vec<Node>> {
} }
fn whitespace0(s: &str) -> IResult<'_, Vec<char>> { fn whitespace0(s: &str) -> IResult<'_, Vec<char>> {
many0(one_of(" \u{3000}")).parse(s) many0(one_of(" \n\u{3000}")).parse(s)
} }
/// Optional leading space, then a (negated) group or text /// Optional leading space, then a (negated) group or text
@ -265,7 +265,7 @@ fn quoted_term(s: &str) -> IResult<'_, Node> {
/// eg deck:"foo bar" - quotes must come after the : /// eg deck:"foo bar" - quotes must come after the :
fn partially_quoted_term(s: &str) -> IResult<'_, Node> { fn partially_quoted_term(s: &str) -> IResult<'_, Node> {
let (remaining, (key, val)) = separated_pair( let (remaining, (key, val)) = separated_pair(
escaped(is_not("\"(): \u{3000}\\"), '\\', none_of(" \u{3000}")), escaped(is_not("\"(): \n\u{3000}\\"), '\\', none_of(" \n\u{3000}")),
char(':'), char(':'),
quoted_term_str, quoted_term_str,
) )
@ -278,7 +278,7 @@ fn partially_quoted_term(s: &str) -> IResult<'_, Node> {
/// Unquoted text, terminated by whitespace or unescaped ", ( or ) /// Unquoted text, terminated by whitespace or unescaped ", ( or )
fn unquoted_term(s: &str) -> IResult<'_, Node> { fn unquoted_term(s: &str) -> IResult<'_, Node> {
match escaped(is_not("\"() \u{3000}\\"), '\\', none_of(" \u{3000}"))(s) { match escaped(is_not("\"() \n\u{3000}\\"), '\\', none_of(" \n\u{3000}"))(s) {
Ok((tail, term)) => { Ok((tail, term)) => {
if term.is_empty() { if term.is_empty() {
Err(parse_error(s)) Err(parse_error(s))
@ -298,7 +298,7 @@ fn unquoted_term(s: &str) -> IResult<'_, Node> {
provided: format!("\\{c}"), provided: format!("\\{c}"),
}, },
)) ))
} else if "\"() \u{3000}".contains(s.chars().next().unwrap()) { } else if "\"() \n\u{3000}".contains(s.chars().next().unwrap()) {
Err(parse_error(s)) Err(parse_error(s))
} else { } else {
// input ends in an odd number of backslashes // input ends in an odd number of backslashes