[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gmediaserver-devel] gmediaserver with libmagic
From: |
Han |
Subject: |
Re: [gmediaserver-devel] gmediaserver with libmagic |
Date: |
Thu, 7 Jan 2010 00:18:10 -0800 |
On Wed, Jan 6, 2010 at 3:02 AM, address@hidden <address@hidden> wrote:
> On Tue, 2010-01-05 at 22:22 -0800, Han wrote:
>> so if the strings don't match 100%, it will not find the correct file
>> type. As shown above, libmagic seems have extra info in the string
>> (i.e. charset), so it failed to match.
>
> Hi
>
> Yeah, this is a problem, but there is a fix in cvs, in the metadata.c
> file.
>
> I think this is the code that removes the trailing charset binary
>
> magic = strpbrk(magic_full, "; ");
> if (magic != NULL) {
> magic = xstrndup(magic_full, magic - magic_full);
> } else {
> magic = xstrdup(magic_full);
> }
>
Thanks a lot for the info. This fix should work, although it adds
overhead by calling xstrndup/xstrdup. Would the following fix be
simpler?
- if (strcmp(magic, mime_map[c].mime) == 0)
+ if (strstr(magic, mime_map[c].mime) == magic)
i.e. check if mime_map[c].mime is same as the beginning part of magic.
"strstr" here can also be "strpbrk" .
thanks.
Han
>