mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +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:
@@ -1,5 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- fix escaping in generated QR-code-SVG #3295
|
||||||
|
|
||||||
## 1.79.0
|
## 1.79.0
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|||||||
@@ -65,13 +65,12 @@ async fn generate_verification_qr(context: &Context) -> Result<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn inner_generate_secure_join_qr_code(
|
fn inner_generate_secure_join_qr_code(
|
||||||
raw_qrcode_description: &str,
|
qrcode_description: &str,
|
||||||
qrcode_content: &str,
|
qrcode_content: &str,
|
||||||
color: &str,
|
color: &str,
|
||||||
avatar: Option<Vec<u8>>,
|
avatar: Option<Vec<u8>>,
|
||||||
avatar_letter: char,
|
avatar_letter: char,
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
let qrcode_description = &escaper::encode_minimal(raw_qrcode_description);
|
|
||||||
// config
|
// config
|
||||||
let width = 515.0;
|
let width = 515.0;
|
||||||
let height = 630.0;
|
let height = 630.0;
|
||||||
@@ -262,3 +261,21 @@ fn inner_generate_secure_join_qr_code(
|
|||||||
|
|
||||||
Ok(svg)
|
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