subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Shahaf <...@daniel.shahaf.name>
Subject Re: svn commit: r1131389 - /subversion/trunk/subversion/libsvn_subr/magic.c
Date Fri, 24 Jun 2011 18:49:31 GMT
stsp@apache.org wrote on Sat, Jun 04, 2011 at 13:04:51 -0000:
> Author: stsp
> Date: Sat Jun  4 13:04:51 2011
> New Revision: 1131389
> 
> URL: http://svn.apache.org/viewvc?rev=1131389&view=rev
> Log:
> Work around older libmagic versions that don't define MAGIC_MIME_TYPE.
> 
> This should fix the centos buildbot.
> 
> * subversion/libsvn_subr/magic.c: 
>   (svn_magic__init): If MAGIC_MIME_TYPE isn't supported use MAGIC_MIME instead.
>   (svn_magic__detect_binary_mimetype): Strip charset information from the
>    string returned by libmagic if MAGIC_MIME was used.
> 
> Modified:
>     subversion/trunk/subversion/libsvn_subr/magic.c
> 
> Modified: subversion/trunk/subversion/libsvn_subr/magic.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/magic.c?rev=1131389&r1=1131388&r2=1131389&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_subr/magic.c (original)
> +++ subversion/trunk/subversion/libsvn_subr/magic.c Sat Jun  4 13:04:51 2011
> @@ -70,7 +70,14 @@ svn_magic__init(svn_magic__cookie_t **ma
>    mc = apr_palloc(result_pool, sizeof(*mc));
>  
>    /* Initialise libmagic. */
> +#ifndef MAGIC_MIME_TYPE
> +  /* Some old versions of libmagic don't support MAGIC_MIME_TYPE.
> +   * We can use MAGIC_MIME instead. It returns more than we need
> +   * but we can work around that (see below). */
> +  mc->magic = magic_open(MAGIC_MIME | MAGIC_ERROR);
> +#else
>    mc->magic = magic_open(MAGIC_MIME_TYPE | MAGIC_ERROR);
> +#endif
>    if (mc->magic)
>      {
>        /* This loads the default magic database.
> @@ -115,6 +122,14 @@ svn_magic__detect_binary_mimetype(const 
>              magic_mimetype = NULL;
>            else
>             {
> +#ifndef MAGIC_MIME_TYPE
> +             char *p;
> +
> +             /* Strip off trailing stuff like " charset=ascii". */
> +             p = strchr(magic_mimetype, ' ');
> +             if (p)
> +              *p = '\0';

What is 'magic_mimetype' here?  Is it guaranteed to contain a space, or
can it be 'text/plain;charset=ascii' ?

i.e., should the strchr look for a semicolon?

(The libmagic ftp mirror is down, and my man page doesn't mention
MAGIC_MIME, so I'm not easily able to check the docs of some old
libmagic version.)


> +#endif
>               /* The string is allocated from memory managed by libmagic so
>                * we must copy it to the result pool. */
>               magic_mimetype = apr_pstrdup(result_pool, magic_mimetype);
> 
> 

Mime
View raw message