Bug 280004

Summary: Bugzilla misidentifies Git patches
Product: Services Reporter: Dag-Erling Smørgrav <des>
Component: Bug TrackerAssignee: Bugmeister <bugmeister>
Status: New ---    
Severity: Affects Some People CC: tatsuki_makino
Priority: ---    
Version: unspecified   
Hardware: Any   
OS: Any   

Description Dag-Erling Smørgrav freebsd_committer freebsd_triage 2024-06-26 10:53:49 UTC
When a patch created by `git format-patch` is attached to a bug, Bugzilla automatically sets its type to `application/mbox` (cf. bug #279999).  This is somewhat understandable since the patch is an email, but it is not in fact an mbox file (which would begin with `"From "` rather than `"From: "`), and this prevents viewing the patch directly in the browser.  Would it be possible to modify Bugzilla to always use `text/x-patch` (or otherwise mark the attachment as being a patch) when the file name ends in `.patch`?
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2024-06-28 20:01:05 UTC
(In reply to Dag-Erling Smørgrav from comment #0)
I cannot find any code in Bugzilla that changes content to application/mbox.

Please open a bug with such a patch on bugstest.FreeBSD.org so I can try to
figure out what happens.

Oh, and Cc: me personally on any email.

mcl
Comment 2 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2024-06-28 20:26:25 UTC
I assume it uses either file(1) or libmagic(3)?
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2024-06-29 19:36:17 UTC
(In reply to Dag-Erling Smørgrav from comment #2)
If it does, it's buried deep in a perl dependency somewhere.
Comment 4 Tatsuki Makino 2024-07-01 08:05:15 UTC
Is it possible to use the mimetype added by the browser when uploading?

attachment 251737 [details] uploaded to bug 278857 seems to be sent with the following mimetype.

chromium-124.0.6367.207: text/x-patch
firefox-126.0.2,2 seamonkey-2.49.4_27: application/octet-stream

However, I checked the checkbox labeled patch, so it seems to be text/plain normally.

Other commands that may be relevant and their results are as follows.

> xdg-mime query filetype 0001-audio-libopenshot-audio-Update-to-0.3.3.patch 
text/x-diff

I hope you find it helpful :)