From: ozzloy <ozzloy@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 63941@debbugs.gnu.org
Subject: bug#63941: [PATCH] ; always CRLF before non-first boundary in multipart form
Date: Sat, 10 Jun 2023 18:38:44 -0700 [thread overview]
Message-ID: <CACT2Onh1KjdmiiMD+fu87=RB9j0ZyYmySomRqmjWtOwFcCKN8Q@mail.gmail.com> (raw)
In-Reply-To: <83sfazzm8x.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 2707 bytes --]
> Making the change in mm-url.el sounds scary: that code was written
> many years ago, and who knows where it is used?
Yeah, that makes sense. I'll see what I can find about that, at least
within emacs itself.
> The reason for testing bolp there is not explained, but I'm guessing
> they didn't want to craete an empty line?
Not sure. It looks like it was introduced during a patch intended to fix
submitting binary data. Would it make sense to CC the two authors of the
following commits?
I dug into the history a bit to try to find out where =(unless (bolp)=
came from
#+begin_src bash
git log -L '/(unless (bolp)/,+1:lisp/gnus/mm-url.el' > unless-bolp
#+end_src
It looks like it was introduced in this commit
#+begin_quote
commit fca2f70380dcb054497470aaf8eda6173063928e
Author: Kenjiro Nakayama <nakayamakenjiro@gmail.com>
Date: Mon Nov 10 22:33:55 2014 +0100
Allow uploading files from eww
#+end_quote
and the "\r\n" was included unconditionally before the boundary
#+begin_src elisp
;; use the boundary as a separator
(concat "\r\n--" boundary "\r\n")
#+end_src
Then it this commit changed it
#+begin_quote
commit a6e0188dffc394698d9ffbef50401f14a31c8722
Author: Lars Ingebrigtsen <larsi@gnus.org>
Date: Thu Oct 13 21:39:29 2016 +0200
Fix problem with submitting binary data via HTTP forms
#+end_quote
to the following
#+begin_src elisp
(unless (bolp)
(insert "\r\n"))
#+end_src
plus a bunch of "\r\n"s scattered throughout the different conditions.
It's not clear to me how the behavior of the function changed.
It looks like maybe instead of the initial diff I proposed, something
like this would produce more accurate output for file uploads, and also
change the surrounding code as little as possible,
#+begin_quote
diff --git a/lisp/gnus/mm-url.el b/lisp/gnus/mm-url.el
index 11847a79f17..686dea20b6a 100644
--- a/lisp/gnus/mm-url.el
+++ b/lisp/gnus/mm-url.el
@@ -430,7 +430,8 @@ mm-url-encode-multipart-form-data
(insert filedata))
;; How can this possibly be useful?
((integerp filedata)
- (insert (number-to-string filedata))))))
+ (insert (number-to-string filedata)))))
+ (insert "\r\n"))
((equal name "submit")
(insert
"Content-Disposition: form-data;
name=\"submit\"\r\n\r\nSubmit\r\n"))
#+end_quote
But it seems like it would be better to do a larger rewrite that
consolidates the places where "\r\n" is added before the non-initial
boundary.
In order to figure that out, I will read the two versions more closely
to figure out what the differences are and write some ERT tests showing
the difference. Hopefully that will clear things up.
[-- Attachment #2: Type: text/html, Size: 3378 bytes --]
next prev parent reply other threads:[~2023-06-11 1:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 5:25 bug#63941: [PATCH] ; always CRLF before non-first boundary in multipart form ozzloy
2023-06-07 12:30 ` Eli Zaretskii
2023-06-08 2:48 ` ozzloy
2023-06-08 6:09 ` Eli Zaretskii
2023-06-08 6:43 ` ozzloy
2023-06-08 6:52 ` ozzloy
2023-06-10 9:42 ` Eli Zaretskii
2023-06-11 1:38 ` ozzloy [this message]
2023-06-18 23:23 ` ozzloy
2023-06-19 16:13 ` Eli Zaretskii
2023-06-22 16:49 ` ozzloy
2023-06-22 18:25 ` ozzloy
2023-06-22 18:29 ` Eli Zaretskii
2023-06-23 8:22 ` ozzloy
2023-07-18 19:04 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-21 9:04 ` ozzloy
2023-08-29 0:28 ` ozzloy
2023-12-02 15:03 ` ozzloy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACT2Onh1KjdmiiMD+fu87=RB9j0ZyYmySomRqmjWtOwFcCKN8Q@mail.gmail.com' \
--to=ozzloy@gmail.com \
--cc=63941@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).