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: Wed, 7 Jun 2023 19:48:29 -0700 [thread overview]
Message-ID: <CACT2OnhhQGsLhKgik+ghW+DDMbeksWY6yh0P0p1-jxFNv36xQg@mail.gmail.com> (raw)
In-Reply-To: <837csf4fp8.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 2147 bytes --]
> please describe in detail what should be done
Sure! I'm not sure what would be too much, and what would be too little
explanation.
The short version is to run the following code,
#+begin_src elisp
(require 'mm-url)
(let ((data '(("file"
("filedata" . "file content\n")
("name" . "file")
("filename" . "filename"))))
(boundary "BOUNDARY"))
(mm-url-encode-multipart-form-data data boundary))
#+end_src
#+RESULTS:
: --BOUNDARY^M
: Content-Disposition: form-data; name="file"; filename="filename"^M
: Content-Transfer-Encoding: binary^M
: Content-Type: text/plain^M
: ^M
: file content
: --BOUNDARY--^M
(I've replaced carriage returns with literal '^' and 'M' to avoid email
mangling)
and observe the absence of CRLF between the file content and the boundary.
From https://www.rfc-editor.org/rfc/rfc2046#section-5.1.1 this description,
it seems like there should be.
Here's a longer set of steps.
0. run http server
#+begin_src bash
git clone https://git.sr.ht/~ozzloy/emacs-bug-63941
cd emacs-bug-63941
git checkout reproduce-bug-63941
./server.py
#+end_src
1. Then use EWW to browse to localhost:8085 and upload the file =filename=.
Here's my result when doing that, first with EWW.
#+begin_quote
upload_content = b'file content', name = 'filename', size = 12
127.0.0.1 - - [07/Jun/2023 18:55:03] "POST / HTTP/1.1" 200 -
#+end_quote
The bug is that the file content no longer has the final "\n".
2. To confirm, in a separate shell, I posted using curl.
#+begin_src bash
curl -F "file=@filename;filename=filename" localhost:8085
#+end_src
Here's the output I got
#+begin_quote
upload_content = b'file content\n', name = 'filename', size = 13
127.0.0.1 - - [07/Jun/2023 18:57:12] "POST / HTTP/1.1" 200 -
#+end_quote
The file's content ends with "\n", which is the expected behavior.
This is the second HTTP file upload server I have used and seen this
behavior. The same thing happened for one I wrote in clojure using
Aleph. That one is here https://git.sr.ht/~ozzloy/fupload but I made the
python one because it's probably less set up for other people to
reproduce it.
[-- Attachment #2: Type: text/html, Size: 2844 bytes --]
next prev parent reply other threads:[~2023-06-08 2:48 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 [this message]
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
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=CACT2OnhhQGsLhKgik+ghW+DDMbeksWY6yh0P0p1-jxFNv36xQg@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).