chiark / gitweb /
LitLinesCrlf: expect input without the final empty line
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 May 2026 10:23:37 +0000 (11:23 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 May 2026 11:05:40 +0000 (12:05 +0100)
Before we got rid of the macro, this was handled by the way the `{}`
were embedded in the format string.

Then it was present in the source, stripped by LitLinesCrlf and then
added back by lines_crlf.  Now it is only handled by lines_crlf and
everything is reasonably straightforward.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
client/client.rs

index e45d1650e3f2b42c1b5241e0e1b10d8a00184e1b..28d39bcedec582c8a40819596167cbde5f9033f6 100644 (file)
@@ -24,7 +24,7 @@ macro_rules! lines_crlf { { $($content:expr),* $(,)? } => {
 
 /// Displays as the lines of `s`, deindented, with CRLFs
 ///
-/// TODO has anomalous handling of the last line.
+/// Missing trailing newline turns into missing trailing `\r\n`
 pub struct LitLinesCrlf<'s>(pub &'s str);
 
 impl Display for LitLinesCrlf<'_> {
@@ -42,7 +42,6 @@ impl Display for LitLinesCrlf<'_> {
     .flatten()
     .collect::<String>();
 
-    let output = output.strip_suffix("\r\n").expect("XXXX bad input");
     write!(f, "{output}")
   }
 }
@@ -112,7 +111,6 @@ fn submit_request<'r, 'c:'r>(
     r#"--b
        Content-Type: text/plain; charset="utf-8"
        Content-Disposition: form-data; name="m"
-
        "#),
                        &c.ic.link.client,
                        token,
@@ -128,13 +126,11 @@ fn submit_request<'r, 'c:'r>(
        --b
        Content-Type: application/octet-stream
        Content-Disposition: form-data; name="d"
-
        "#),
   );
   let suffix = lines_crlf!(&LitLinesCrlf(
     r#"
-       --b--
-       "#),
+       --b--"#),
   );
 
   macro_rules! content { {