Fix encoding for email & name, fix qrencode command in repl

This commit is contained in:
jikstra
2019-09-04 16:37:45 +02:00
committed by holger krekel
parent ff6a4d18cf
commit ae612e07dc
2 changed files with 7 additions and 4 deletions

View File

@@ -525,7 +525,7 @@ unsafe fn handle_cmd(line: &str, ctx: Arc<RwLock<Context>>) -> Result<ExitResult
} }
println!("{}", qr); println!("{}", qr);
let output = Command::new("qrencode") let output = Command::new("qrencode")
.args(&["-t", "ansiutf8", format!("\"{}\"", qr.as_str()).as_str(), "-o", "-"]) .args(&["-t", "ansiutf8", qr.as_str(), "-o", "-"])
.output() .output()
.expect("failed to execute process"); .expect("failed to execute process");
io::stdout().write_all(&output.stdout).unwrap(); io::stdout().write_all(&output.stdout).unwrap();

View File

@@ -1,5 +1,5 @@
use mmime::mailimf_types::*; use mmime::mailimf_types::*;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC}; use percent_encoding::{utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC};
use std::ptr; use std::ptr;
use crate::aheader::EncryptPreference; use crate::aheader::EncryptPreference;
@@ -22,6 +22,9 @@ use crate::stock::StockMessage;
use crate::types::*; use crate::types::*;
use crate::x::*; use crate::x::*;
pub const NON_ALPHANUMERIC_WITHOUT_DOT: &AsciiSet = &NON_ALPHANUMERIC
.remove(b'.');
pub unsafe fn dc_get_securejoin_qr( pub unsafe fn dc_get_securejoin_qr(
context: &Context, context: &Context,
group_chat_id: uint32_t, group_chat_id: uint32_t,
@@ -76,8 +79,8 @@ pub unsafe fn dc_get_securejoin_qr(
return cleanup(fingerprint, qr); return cleanup(fingerprint, qr);
} }
let self_addr_urlencoded = utf8_percent_encode(&self_addr, NON_ALPHANUMERIC).to_string(); let self_addr_urlencoded = utf8_percent_encode(&self_addr, NON_ALPHANUMERIC_WITHOUT_DOT).to_string();
let self_name_urlencoded = utf8_percent_encode(&self_name, NON_ALPHANUMERIC).to_string(); let self_name_urlencoded = utf8_percent_encode(&self_name, NON_ALPHANUMERIC_WITHOUT_DOT).to_string();
qr = if 0 != group_chat_id { qr = if 0 != group_chat_id {
if let Ok(chat) = Chat::load_from_db(context, group_chat_id) { if let Ok(chat) = Chat::load_from_db(context, group_chat_id) {