diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-06-20 11:42:45 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-06-24 19:00:37 +0200 |
commit | d1c9bd08e23aa8901028dceb1e63cb8fd7ae5ddc (patch) | |
tree | cb6fa4c7af585b260123630d8d66866c206936d3 /ipc/src | |
parent | 8c2fe1cd84d0bab1e56d3ad96e7818697a7ac4ab (diff) |
ipc: Fix handling of data lines.
Diffstat (limited to 'ipc/src')
-rw-r--r-- | ipc/src/assuan/mod.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/ipc/src/assuan/mod.rs b/ipc/src/assuan/mod.rs index 0d5110b0..a24c48e8 100644 --- a/ipc/src/assuan/mod.rs +++ b/ipc/src/assuan/mod.rs @@ -93,22 +93,27 @@ impl Client { let mut data = data.as_ref(); let mut request = Vec::with_capacity(data.len()); while ! data.is_empty() { - let line_len = 2; if request.len() > 0 { request.push(0x0a); } write!(&mut request, "D ").unwrap(); + let mut line_len = 2; while ! data.is_empty() && line_len < MAX_LINE_LENGTH - 3 { let c = data[0]; data = &data[1..]; match c as char { - '%' | '\n' | '\r' => - write!(&mut request, "%{:02X}", c).unwrap(), - _ => request.push(c), + '%' | '\n' | '\r' => { + line_len += 3; + write!(&mut request, "%{:02X}", c).unwrap(); + }, + _ => { + line_len += 1; + request.push(c); + }, } } } - write!(&mut request, "END").unwrap(); + write!(&mut request, "\nEND").unwrap(); self.send(request) } } |