Skip to content

fix MAGIC_MIME_TYPE value#70

Closed
yangjuven wants to merge 1 commit intoahupp:masterfrom
yangjuven:master
Closed

fix MAGIC_MIME_TYPE value#70
yangjuven wants to merge 1 commit intoahupp:masterfrom
yangjuven:master

Conversation

@yangjuven
Copy link
Copy Markdown

In https://github.com/file/file/blob/master/src/magic.h.in#L44 , the macro are defined as follows:

#define MAGIC_MIME_TYPE     0x000010 /* Return the MIME type */
#define MAGIC_MIME_ENCODING 0x000400 /* Return the MIME encoding */
#define MAGIC_MIME      (MAGIC_MIME_TYPE|MAGIC_MIME_ENCODING)

But in https://github.com/ahupp/python-magic/blob/master/magic.py#L279 , variables are defined as follows:

MAGIC_MIME = 0x000010 # Return a mime string

MAGIC_MIME_ENCODING = 0x000400 # Return the MIME encoding

So is this a bug? Fix it:

MAGIC_MIME_TYPE = 0x000010 # Return a MIME type

MAGIC_MIME_ENCODING = 0x000400 # Return the MIME encoding

MAGIC_MIME = MAGIC_MIME_TYPE | MAGIC_MIME_ENCODING

@ahupp
Copy link
Copy Markdown
Owner

ahupp commented Jan 6, 2015

I'm concerned that this will be a backwards-incompatible change. In what cases does this change the output? Do you end up with something like 'text/plain; charset=utf-8"?

@ahupp
Copy link
Copy Markdown
Owner

ahupp commented Jan 6, 2015

My best guess is that magic.h changed after I copied the definitions into python.

ahupp added a commit that referenced this pull request May 5, 2020
Not going to change the value of MAGIC_MIME until a major version
bump, but at least add the missing MAGIC_MIME_TYPE constant and use
where it should be.

#70
@ahupp
Copy link
Copy Markdown
Owner

ahupp commented May 5, 2020

I've pushed a fix for this (will go in next major release) that updates the constants but preserves the library behavior.

@ahupp ahupp closed this May 5, 2020
jenniferlb63 added a commit to jenniferlb63/python-magic that referenced this pull request Aug 6, 2023
Not going to change the value of MAGIC_MIME until a major version
bump, but at least add the missing MAGIC_MIME_TYPE constant and use
where it should be.

ahupp/python-magic#70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants