On 01/08/2016 07:44 PM, William A Rowe Jr wrote:
Do we have to repeat the softmagic call if checkzmagic resolves to
x-gzip/x-deflate and the internal content type needs to be deciphered?

That's true.

I think that Yann's patch moving the zmagic call after the softmagic call would just mean that zmagic won't be called at all if the softmagic recognizes the file format.

We would have to check the softmagic result by something similar to "magic_rsl_to_request" and if it's type we want to decompress, we would have to run zmagic.

Before really trying to do so, I want to ask if I understand the reasoning right. Do we consider this way because users can then remove x-gzip from mime magic and will be able to use it to disable the mod_mime_magic behaviour discussed in this thread?

Regards,
Jan Kaluza

If so, a tweak to this patch sounds like a winner, and could selectively
recognize different inflation streams including bzip2 etc.

On Fri, Jan 8, 2016 at 10:57 AM, Yann Ylavic <ylavic....@gmail.com
<mailto:ylavic....@gmail.com>> wrote:

    On Fri, Jan 8, 2016 at 5:30 PM, Yann Ylavic <ylavic....@gmail.com
    <mailto:ylavic....@gmail.com>> wrote:
    > On Fri, Jan 8, 2016 at 3:17 PM, William A Rowe Jr <wr...@rowe-clan.net 
<mailto:wr...@rowe-clan.net>> wrote:
    >>
    >> Agreed it is configuration, but cant we simply tweak our recommended
    >> conf/magic
    >> file???
    >>
    >> # standard unix compress
    >> # Enable the alternate line below to present gzip content as a transfer
    >> encoded
    >> # stream of the underlying content;
    >> #0       string          \037\235        application/octet-stream
    >> x-compress
    >> 0       string          \037\235        application/octet-stream
    >>
    >> # gzip (GNU zip, not to be confused with [Info-ZIP/PKWARE] zip archiver)
    >> # Enable the alternate line below to present gzip content as a transfer
    >> encoded
    >> # stream of the underlying content;
    >> #0       string          \037\213        application/octet-stream
    >> x-gzip
    >> 0       string          \037\213        application/octet-stream
    >>
    >> WDYT?
    >
    > I wasn't aware of conf/magic file, but it seems not used by zmagic()
    > which hardcodes its types.
    > I may be missing something though...

    Looks like it is already like this in conf/magic of 2.4.x and 2.2.x.
    My bet is that zmagic() is run before softmagic(), so the magic file
    is of no help.

    Maybe a simpler patch could be:

    Index: modules/metadata/mod_mime_magic.c
    ===================================================================
    --- modules/metadata/mod_mime_magic.c    (revision 1723283)
    +++ modules/metadata/mod_mime_magic.c    (working copy)
    @@ -880,14 +885,6 @@ static int tryit(request_rec *r, unsigned char *bu
                       int checkzmagic)
      {
          /*
    -     * Try compression stuff
    -     */
    -    if (checkzmagic == 1) {
    -        if (zmagic(r, buf, nb) == 1)
    -            return OK;
    -    }
    -
    -    /*
           * try tests in /etc/magic (or surrogate magic file)
           */
          if (softmagic(r, buf, nb) == 1)
    @@ -900,6 +897,14 @@ static int tryit(request_rec *r, unsigned char *bu
              return OK;

          /*
    +     * Try compression stuff
    +     */
    +    if (checkzmagic == 1) {
    +        if (zmagic(r, buf, nb) == 1)
    +            return OK;
    +    }
    +
    +    /*
           * abandon hope, all ye who remain here
           */
          return DECLINED;
    --



Reply via email to