Closed
Bug 621478
Opened 15 years ago
Closed 15 years ago
Create ContentType sniffing bugzilla extension for when Attachment auto-detection yields poor results
Categories
(bugzilla.mozilla.org :: General, defect)
bugzilla.mozilla.org
General
Tracking
()
RESOLVED
FIXED
People
(Reporter: rob1weld, Assigned: gerv)
References
Details
(Whiteboard: [wanted-bmo])
Attachments
(2 files, 1 obsolete file)
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Build Identifier:
The "Bug Report Attachment Auto-detection" at bugzilla.mozilla.org does not work correctly.
When I visit https://bugzilla.mozilla.org/ to file Bug Reports for Firefox I sometimes attach a textual Log file. If I do not specify it is text but use "Auto Detection" then the file is often detected as an "octet stream".
For the sake of the "search features" it is better if it is changed to text (by an Admin) and would be easiest for everyone if it were set correctly in the first place.
I do not understand why it is complicated to read the first 100 characters and fathom a reasonable guess as to whether it is a textual based content or not.
In the event that this were not possible there is a great Program called "file" ( http://en.wikipedia.org/wiki/File_(command) )that can differentiate between almost all file types without error.
Thanks,
Rob
Reproducible: Always
| Assignee | ||
Comment 1•15 years ago
|
||
Rob: Bugzilla's auto-detection uses the information sent by your browser to determine what content type to pick. If your browser sends it an application/octet-stream, that's what Bugzilla will put.
In order to persuade your browser to upload the log file with a text/plain content type, it may help to give it a ".txt" extension. (Also, if you are on a Mac, I believe the Mac has other mechanisms for indicating the type of a file.)
Sniffing content types from the contents is error-prone and can lead, in some circumstances, to security problems (although less with uploading than downloading).
Gerv
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → WONTFIX
gerv: we need to talk about this. a large portion of the attachments we get these days are windbg log files. the attachment auto detection results in application/octet-stream and causes a lot of wasted effort on my part. it also causes a lot of confusion on the part of users.
Status: RESOLVED → REOPENED
Ever confirmed: true
Keywords: regression
Resolution: WONTFIX → ---
Summary: Attachment Auto-detection at bugzilla.mozilla.org does not work. → Attachment Auto-detection at bugzilla.mozilla.org is confusing and disingenuous
| Assignee | ||
Comment 3•15 years ago
|
||
Well, we could start by changing the instructions people are following to generate such files, to say "please rename it to .txt before uploading".
Hmm. This might be an upstream change. But then, perhaps an extension could do it as well... Let me see.
Gerv
| Assignee | ||
Comment 4•15 years ago
|
||
Here is the Extension.pm for a new "CTSniff" extension I just knocked up. It's very simple - when we are autodetecting, and the check of Content-Type comes back as application/octet-stream, we try and make a better guess using a Perl module interface to "magic" data.
Max: could you give me quick feedback here? I am looking for advice particularly on three questions:
1) Is this the sort of function you would be interested in seeing as an optional (as in, 'if you have the module installed') feature in core Bugzilla?
2) What do you think of the commented workaround for CGI.pm's filehandle brokenness?
3) Is $data on attachment creation ever a scalar, or is it always a filehandle? Under what conditions is it a scalar?
Thank you :-)
Gerv
I'm not going to waste my time filing bugs against bugzilla product, they don't get addressed and they get rude resolutions. if you want to file a bug upstream, be my guest.
and no, we are not going to change instructions on dozens of wiki pages asking people to do more work, we're already asking them to do lots of work.
thank you for reconsidering and putting some code to paper.
Comment 6•15 years ago
|
||
This should totally go upstream, but I have no issue with it being implemented as an extension until the upstream code makes it to bmo.
Updated•15 years ago
|
Keywords: regression
OS: Windows XP → All
Hardware: x86 → All
Summary: Attachment Auto-detection at bugzilla.mozilla.org is confusing and disingenuous → Attachment auto-detection is confusing and disingenuous
Comment 7•15 years ago
|
||
Comment on attachment 499837 [details]
CTSniff Extension.pm
Yeah, I'd be interested in having this in core. However, you'll want to wait until after bug 577532.
>
>our $VERSION = '0.01';
>use File::MimeInfo::Magic;
This means you need a Config.pm for this extension.
>sub attachment_process_data {
> my ($self, $args) = @_;
> my $attributes = $args->{'attributes'};
> my $cgi = Bugzilla->cgi;
This is also called in the WebService, so you should use Bugzilla->input_params instead.
> # data attribute can apparently be either scalar data or filehandle
> # bugzilla.org/docs/3.6/en/html/api/Bugzilla/Attachment.html#create
> # Although it always seems to be a filehandle to me...
It's a scalar when used via the WebService. Probably also during migrate.pl.
> # Work around brokenness of CGI.pm's filehandles. See:
> # http://www.perlmonks.org/?node_id=606837
> push @Fh::ISA, 'IO::Handle' unless Fh->isa('IO::Handle');
> push @Fh::ISA, 'IO::Seekable' unless Fh->isa('IO::Seekable');
Ah, no, you want $fh->handle. See bug 577532.
Attachment #499837 -
Flags: feedback?(mkanat) → feedback-
bug 617708 notes that users also end up attaching files as text/x-log, which is another case that's rather annoying.
Summary: Attachment auto-detection is confusing and disingenuous → Create ContentType sniffing bugzilla extension for when Attachment auto-detection yields poor results
| Assignee | ||
Comment 10•15 years ago
|
||
OK, here's a v2 with those fixes. I do already have a Config.pm, which contains the obvious (File::MimeInfo::Magic and IO::Scalar as required modules).
Would it be reasonable to check this in to
http://bzr.mozilla.org/bugzilla/extensions/
? If so, is that something within my power?
Gerv
Attachment #499837 -
Attachment is obsolete: true
Attachment #499996 -
Flags: feedback?(mkanat)
Comment 11•15 years ago
|
||
It would be reasonable to check in there. It may or may not be within your power, but if it isn't, let me know and I will create a branch for you there.
| Assignee | ||
Comment 12•15 years ago
|
||
mkanat: looking at that repo, it looks like the emerging convention for extension names is to use lowercase. Is that correct, or not?
Gerv
Updated•15 years ago
|
Attachment #499996 -
Attachment mime type: text/x-perl → text/plain
Comment 13•15 years ago
|
||
(In reply to comment #12)
> mkanat: looking at that repo, it looks like the emerging convention for
> extension names is to use lowercase. Is that correct, or not?
For the repo, yeah. It makes the bzr urls easier to type. The checked-out extension should still be uppercase, though.
| Assignee | ||
Comment 14•15 years ago
|
||
Doesn't look like I have permission. mkanat: please can you create me a repo under bugzilla/extensions/ called "typesniffer"? (I've changed the name :-)
Gerv
Comment 15•15 years ago
|
||
Okay, I've made typesniffer/trunk. You should be able to create a branch in that directory, or at least write to it. (bzr will ask you about using an existing directory, I think you'll have to pass a switch, but bzr will explain it.) It may take a few hours for the server to run the cron job that fixes the permissions that let you upload there.
| Assignee | ||
Comment 16•15 years ago
|
||
The typesniffer extension is now here:
http://bzr.mozilla.org/bugzilla/extensions/typesniffer/trunk/changes
I will make it part of the bmo-4.0 effort.
Gerv
| Reporter | ||
Comment 17•15 years ago
|
||
(In reply to comment #1)
> Rob: Bugzilla's auto-detection uses the information sent by your browser to
> determine what content type to pick. If your browser sends it an
> application/octet-stream, that's what Bugzilla will put.
My Browser is ...... Firefox .
> In order to persuade your browser to upload the log file with a text/plain
> content type, it may help to give it a ".txt" extension. (Also, if you are on a
> Mac, I believe the Mac has other mechanisms for indicating the type of a file.)
I have a "PC" and it thinks ".log" files ought to be opened using "Notepad" since I set such an Association. If I open the file (and there is no "Font Error") and can read most of it (it does not look like a 'Debug Dump') then it is "textual" (to me).
> Sniffing content types from the contents is error-prone and can lead, in some
> circumstances, to security problems (although less with uploading than
> downloading).
> Gerv
So we (us Bug Repairer's and Developers) claim to "offer a Service" (to Users) but really we do not. Rather than have our Users trust their settings and submit the Report they (some of us 'not very sophisticated' when it comes to using Computers) need to check to make certain that YOUR (Mozilla's) Computer does what we thought it said it would do.
Would it be easier to simply set all the Uploads to "textual" rather than assume they are "application"; what exactly would YOU _DO_ with an "application" (either an Executable or just a bunch of random text), do you intend to download it and run it on your Computer at home ? --- UNLIKELY.
(In reply to comment #1)
> I'm not going to waste my time filing bugs against bugzilla product, they don't
> get addressed and they get rude resolutions. if you want to file a bug
> upstream, be my guest.
If we are to use their Product we should work on FIXING 'that' as our "New Years Resolution".
> and no, we are not going to change instructions on dozens of wiki pages asking
> people to do more work, we're already asking them to do lots of work.
We could change just the ONE Page with the "false claim"; but better still would be to 'live up to the claim' and offer the SIMPLE Service.
> thank you for reconsidering and putting some code to paper.
We NOW have a great plan. Why have it the way it was; forcing everyone to do more work or leave it broken.
-----
I notice at URL http://bzr.mozilla.org/bugzilla/extensions/typesniffer/trunk/revision/1 that config.pm is 'flagged' as "'\\ No newline at end of file'" .
Thanks for coming together to fix this everyone,
Rob
Updated•15 years ago
|
Whiteboard: [wanted-bmo]
| Reporter | ||
Comment 18•15 years ago
|
||
(In reply to comment #16)
> The typesniffer extension is now here:
> http://bzr.mozilla.org/bugzilla/extensions/typesniffer/trunk/changes
> I will make it part of the bmo-4.0 effort.
> Gerv
In regards to the attachment of 621478 I notice one thing that might trip us up.
I tested this problem on my System and it seems that "file" does not detect encoding in some Files and that we may wish to snoop a bit to determine it.
One place where the problem occurs is in Python Files (which _might_ be a useful and common attachment) and their use of encoding. The Program 'file' can detect it is a "Python script text executable" but then it gives up.
If there is any encoding then that is not detected by 'file'. That COULD affect the contents of the File and introduce Bugs. Some people would be testing and approving Code that is different on different people's Computers (depending on env. var. LANG, etc.).
PEP 0263 - Defining Python Source Code Encodings
http://opsrc.org/dev/peps/pep-0263/
It would seem that if we have any of 'unknown' number of file types that 'file' does not detect the encoding for then we need to read a bit of the Script for those file type on the list, to look for this following encoding line, and either convert the encoding to Mozilla Org's OS's (or preserve the encoding and use it when the File is downloaded):
# -*- coding: ????? -*-
Thanks,
Rob
| Assignee | ||
Comment 20•15 years ago
|
||
<b>Rob</b>: The purpose of this extension is to get the MIME type right. Yes, we could also do character set autodetection for text/* MIME types, but editors and browsers do that already when you download and try and view the file, so there's not much benefit in us doing it.
Gerv
Comment 21•15 years ago
|
||
Comment on attachment 499996 [details]
CTSniff Extension.pm v.2
> if ($params->{'contenttypemethod'} eq 'autodetect' &&
> $attributes->{'mimetype'} eq 'application/octet-stream')
Note that your extension won't fix bug 617708, as Firefox passed text/x-log to Bugzilla.
| Assignee | ||
Comment 22•15 years ago
|
||
| Assignee | ||
Comment 23•15 years ago
|
||
Hmm. Looks like this hasn't been deployed on b.m.o. yet - I thought it went in the last update?
Gerv
| Reporter | ||
Comment 24•15 years ago
|
||
(In reply to comment #20)
> <b>Rob</b>: The purpose of this extension is to get the MIME type right. Yes,
> we could also do character set autodetection for text/* MIME types, but editors
> and browsers do that already when you download and try and view the file, so
> there's not much benefit in us doing it.
> Gerv
I was thinking about how it might be when <b>uploaded</b> and the Search Engine has to deal with it, how it might be if someone viewed the Results or if it was spewed to the mailing list in textual format ... but I'm not writing the Patch.
This BR started out with good intentions, wound up as "WONTFIX", now it has two Dupes, so it may yet take on a life of it's own.
Thanks for working on this, it will be good for everyone (and _other_ BugZilla Sites).
Rob
Comment 25•15 years ago
|
||
This is now live.
Status: ASSIGNED → RESOLVED
Closed: 15 years ago → 15 years ago
Resolution: --- → FIXED
Comment 26•15 years ago
|
||
Is this live only here or on landfill as well?
I don't think it's a good idea to add loads of test attachments here.
Thanks
| Reporter | ||
Comment 27•15 years ago
|
||
Reporter: Assuming this IS fixed (without adding an attachment), so thank you one and all on behalf of the Admins, Timeless, other Bugzilla sites, and me,
Rob
| Assignee | ||
Updated•15 years ago
|
Attachment #499996 -
Flags: feedback?(mkanat)
Updated•15 years ago
|
Component: Bugzilla: Other b.m.o Issues → General
Product: mozilla.org → bugzilla.mozilla.org
You need to log in
before you can comment on or make changes to this bug.
Description
•