Bugzilla converts patch to CRLF line endings?
stb at lassitu.de
Wed Mar 28 11:43:26 UTC 2018
> Am 27.03.2018 um 21:41 schrieb Oleksandr Tymoshenko <gonzo at bluezbox.com>:
> Stefan Bethke (stb at lassitu.de) wrote:
>> I’ve submitted patched for the ports I maintain by copy/pasting the svn diff output into the Bugzilla attachment form for a long time. The committer working on https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=226941 noticed that the patch apparently has CRLF line endings, making it hard(er) to apply it properly.
>> Working on a Mac with Terminal and Safari, I have not have noticed any such behaviour. When I copy/paste from Bugzilla into Terminal, everything works just fine, so I can do „cd /usr/ports/cat/port; patch -p0“ then paste and ^D.
>> When I download the attachment from the „raw“ attachment link (in my example https://bz-attachments.freebsd.org/attachment.cgi?id=191852) with curl or wget, I do get to see CR-LF.
>> Where does that happen? And is that a bug or a feature?
> I think it's a standard: https://stackoverflow.com/a/14217315
> Looks like browser is supposed to convert newlines in input field
> to CR LF. I just tried it on our test instance \r\n-s are part
> of a request, not added later. Bugzilla doesn't perfomr any
> transformation of copy-pasted attachment text and saves it as-is.
That's an unfortunate feature of Bugzilla then, considering that it offers users to copy/paste patches into a textarea field, and subsequently allows users to download the patch again, with the line endings unmodified from the transport encoding.
Interestingly, it is possible to download a patch file with correct line endings by using the correct link. If you follow the link with the file description as it's name, you get the data as submitted, with the wrong line endings: https://bugs.freebsd.org/bugzilla/attachment.cgi?id=191852 <https://bugs.freebsd.org/bugzilla/attachment.cgi?id=191852>
If you click on the "Diff" link, then download the "Raw Unified" link, you'll get a file with correct line endings: https://bugs.freebsd.org/bugzilla/attachment.cgi?id=191852&action=diff&collapsed=&headers=1&format=raw <https://bugs.freebsd.org/bugzilla/attachment.cgi?id=191852&action=diff&collapsed=&headers=1&format=raw>
(This only works if the attachment has been marked as a patch.)
Would it be a good idea to add instructions to either the attachment upload or download page to explain about the line endings situation?
Stefan Bethke <stb at lassitu.de> Fon +49 151 14070811
More information about the freebsd-hackers