Skip to content

Commit 865ede3

Browse files
committed
fix: Properly escape target in receive_imf_inner()
The bug was made in 44227d7. Sql::execute() with placeholders must be used to escape strings, one never should escape them manually as strings themselves can contain escape symbols. Thanks to @link2xt for noticing.
1 parent a27e84a commit 865ede3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/receive_imf.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,18 @@ pub(crate) async fn receive_imf_inner(
458458
};
459459
if target.is_some() || rfc724_mid_orig != rfc724_mid {
460460
let target_subst = match &target {
461-
Some(target) => format!("target='{target}',"),
462-
None => "".to_string(),
461+
Some(_) => "target=?1,",
462+
None => "",
463463
};
464464
context
465465
.sql
466466
.execute(
467-
&format!("UPDATE imap SET {target_subst} rfc724_mid=?1 WHERE rfc724_mid=?2"),
468-
(rfc724_mid_orig, rfc724_mid),
467+
&format!("UPDATE imap SET {target_subst} rfc724_mid=?2 WHERE rfc724_mid=?3"),
468+
(
469+
target.as_deref().unwrap_or_default(),
470+
rfc724_mid_orig,
471+
rfc724_mid,
472+
),
469473
)
470474
.await?;
471475
}

0 commit comments

Comments
 (0)