Coder Social home page Coder Social logo

tree_magic's People

Contributors

aahancoc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tree_magic's Issues

Tests are failing on master

I forked tree_magic because I'd like to submit a PR that updates its deps, but I don't have confidence I won't break anything because some tests are failing for me on master (nightly rust, macOS)

running 16 tests
test from_u8::application_zip ... ok
test from_u8::application_x_7z ... ok
test from_u8::image_gif ... ok
test from_u8::image_png ... ok
test from_u8::image_bmp ... ok
test from_u8::application_tar ... ok
test from_u8::image_tiff ... ok
test from_u8::image_x_portable_bitmap ... ok
test from_u8::image_x_pcx ... ok
test from_u8::image_x_tga ... ok
test from_u8::text_plain ... ok
test from_u8::audio_ogg ... FAILED
test from_u8::audio_opus ... FAILED
test from_u8::audio_mpeg ... ok
test from_u8::audio_wav ... FAILED
test from_u8::audio_flac ... ok

failures:

---- from_u8::audio_ogg stdout ----
thread 'from_u8::audio_ogg' panicked at 'assertion failed: `(left == right)`
  left: `"audio/x-vorbis+ogg"`,
 right: `"audio/ogg"`', tests/from_u8.rs:118:3
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

---- from_u8::audio_opus stdout ----
thread 'from_u8::audio_opus' panicked at 'assertion failed: `(left == right)`
  left: `"audio/x-opus+ogg"`,
 right: `"audio/opus"`', tests/from_u8.rs:126:3

---- from_u8::audio_wav stdout ----
thread 'from_u8::audio_wav' panicked at 'assertion failed: `(left == right)`
  left: `"application/x-riff"`,
 right: `"audio/wav"`', tests/from_u8.rs:134:3


failures:
    from_u8::audio_ogg
    from_u8::audio_opus
    from_u8::audio_wav

Using from_u8/match_u8 with data pulled from streams

The case, when file data pulled from stream, requires little different API because we don't sure that we have enough data.

I think from_u8() and match_u8() should return Option<_> where None means "not enough data to determine".

Contains sources licensed under the GNU GPL

Filing this issue mainly for awareness, since it may be important to some users of this crate: This package lists its license as “MIT,” but the database files in the builtin directory were released by the FreeDesktop project under the GNU GPL. Developers should be careful to avoid violating the GPL when distributing programs that include this crate.

The tree_magic_mini fork of this crate offers an option to build without the GPLed database files. For details, see: mbrubeck#1

Misidentification of image/jpeg files

Problem

All of the JPG files I have tried returns text/plain.

Story

I want to use tree_magic 0.2.3, for validating user content uploaded being uploaded to my website (using actix).
The files being uploaded are being assigned a uuid filename. I discard the filename provided by the user, since it cannot be trusted.

I have tried both using the from_u8() and the from_filepath().

If the path ends in .jpg then tree_magic classified the file correctly as image/jpeg.
However I cannot trust that the user have provided the correct file extension.

Interestingly all the PNG files I have tried with are identified correctly as image/png.
The PNG identification works no matter what file extension I'm using, and I can leave it entirely out.

from_filepath and match_filepath seem to disagree for "text/html"

Cargo.toml:

[package]
name = "blah"
version = "0.1.0"

[dependencies]
tree_magic="0.2.0"

index.html:

<!DOCTYPE html>

src/lib.rs:

extern crate tree_magic;

#[cfg(test)]
mod tests {

    use super::*;
    use std::path::Path;

    static MIME: &str = "text/html";
    static FILE: &str = "index.html";

    #[test]
    fn from_filepath() {
        assert_eq!(MIME, tree_magic::from_filepath(Path::new(FILE)));
    }

    #[test]
    fn match_filepath() {
        assert!(tree_magic::match_filepath(MIME, Path::new(FILE)));
    }
}

Running cargo test on the above project shows ´from_filepathpassing andmatch_filepathfailing.from_filepath` seems to pass as long as the HTML file has DOCTYPE html, ignoring everything else.

Semver breaking change in v0.2.2

First, thanks for this crate. It's the nicest MIME type detector I've found in pure Rust.

I'm using it as a library, and the v0.2.2 release made a breaking change to the API, namely tree_magic::from_filepath now returns an Option.

I've gone ahead and changed my crate's version requirement to be = 0.2.1 until I can update it, but in the future it'd be helpful if changes like this could be accompanied by a minor version bump.

Looking for new maintainer

Hello. Sorry for abandoning this project. I mostly made it to learn how to program in Rust, and didn't really expect people to use it. That said I'm glad everyone finds it useful.

I'm not in a position where I have a lot of time to dedicate to maintaining this (and also it was a little too ambitious for my Rust skills), so if an active contributor would rather take charge I think that would be much better.

Misidentification of docx files

It seems .docx is missing in mime database.
I don't sure this is problem of treemagic itself.

doc.doc:
    magic: application/msword
    treemagic: application/msword
doc.odt:
    magic: application/vnd.oasis.opendocument.text
    treemagic: application/vnd.oasis.opendocument.text
doc.docx:
    magic: application/vnd.openxmlformats-officedocument.wordprocessingml.document
    treemagic: application/zip

Detecting application/json

Currently JSON files do not seem to be detected properly, but instead detected as application/json. Is this planned, or out of scope?

nom v4

It would be very cool if you would update obsolete nom v2 to latest v4. I tried to do that update myself, but it turned out to be not trivial.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.