mirror of
https://github.com/chatmail/core.git
synced 2026-04-18 22:16:30 +03:00
fix qr-code display (#3295)
* tagger.put_raw() has changes sematics and escapes strings on its own now an explicit escaping leads to double escaping and to wrong display. this should also improve lenght calculation, as a quote and other specials counts as 1 character and not as 4-6. * test encoding of generated qr-code-svg * streamline function argument wording use qrcode_description instead of raw_qrcode_description - there is nothing "raw" in the argument, it is a string as used throughout the app.
This commit is contained in:
@@ -65,13 +65,12 @@ async fn generate_verification_qr(context: &Context) -> Result<String> {
|
||||
}
|
||||
|
||||
fn inner_generate_secure_join_qr_code(
|
||||
raw_qrcode_description: &str,
|
||||
qrcode_description: &str,
|
||||
qrcode_content: &str,
|
||||
color: &str,
|
||||
avatar: Option<Vec<u8>>,
|
||||
avatar_letter: char,
|
||||
) -> Result<String> {
|
||||
let qrcode_description = &escaper::encode_minimal(raw_qrcode_description);
|
||||
// config
|
||||
let width = 515.0;
|
||||
let height = 630.0;
|
||||
@@ -262,3 +261,21 @@ fn inner_generate_secure_join_qr_code(
|
||||
|
||||
Ok(svg)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[async_std::test]
|
||||
async fn test_svg_escaping() {
|
||||
let svg = inner_generate_secure_join_qr_code(
|
||||
"descr123 \" < > &",
|
||||
"qr-code-content",
|
||||
"#000000",
|
||||
None,
|
||||
'X',
|
||||
)
|
||||
.unwrap();
|
||||
assert!(svg.contains("descr123 " < > &"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user