Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text files not recognised by magic #57

Closed
WalterS opened this issue Mar 2, 2018 · 9 comments
Closed

Text files not recognised by magic #57

WalterS opened this issue Mar 2, 2018 · 9 comments

Comments

@WalterS
Copy link

WalterS commented Mar 2, 2018

Somehow plaintext files are not recognised:

irb>> MimeMagic::VERSION
=> "0.3.2"
irb>> file = '/tmp/foo'
=> "/tmp/foo"
irb>> File.write(file, 'This is a text file')
=> 19
irb>> MimeMagic.by_magic(file)
=> nil
@georgechang0117
Copy link

I've got the same problem.

1 similar comment
@jonnynux
Copy link

I've got the same problem.

@jonnynux
Copy link

I confirm the issue, every plain textual file like csv, json, css, txt are not recognized. The workaround is to return text/plain if the result of by_magic is nil, but this will make some side effects (example for application/octet-stream. Other suggestions?

@jamesremuscat
Copy link

It appears to only detect text files by magic if the files begin with the strings:

  • This is TeX,; or
  • This is METAFONT,

Needless to say, this would only appear to cover a minimal subset of text files.

@seabre
Copy link

seabre commented Apr 19, 2019

I have a proposed PR for testing for CSVs: #75

@minad
Copy link
Collaborator

minad commented Apr 19, 2019

Is it possible to test via file extension and then via magic? This should handle the tex, json, css, csv cases.

@seabre
Copy link

seabre commented Apr 19, 2019

If you want to be able to match and be mostly sure, you have to parse at least part of the file. I'm not sure with the current setup that you actually can correctly check for CSVs, JSON, CSS, and etc. You can check by extension, but I can do that without the library.

@kelly-croswell
Copy link

Has any movement been made on this? I just ran into this problem on a project I'm working on and could really use a solution.

@minad
Copy link
Collaborator

minad commented Jan 30, 2021

Invalid, this should be fixed in the shared-mime-info database upstream.

@minad minad closed this as completed Jan 30, 2021
@mimemagicrb mimemagicrb locked as resolved and limited conversation to collaborators Mar 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants