[viewvc-dev] Re: [viewvc-users] Don't display binary files

JJ <[email protected]> Fri, 14 Nov 2008 09:08:59 -0600
Newsgroups gmane.comp.version-control.cvs.viewcvs.devel
Message-ID <eed30ed90811140708g33c6d4a0m685ab0e9bfc6439c__19600.3189696514$1226675426$gmane$org@mail.gmail.com>
No, that last patch I sent you doesn't add processing to determine if links
to diff, annotate, etc. should be shown.  I was suggesting that if
template modifiers don't want those links to be shown they can do so using
some variable based on mime types alone.

The patch only adds the processing when actually marking up a file.  At that
point the file is already going to be opened anyway.  I just added code to
check the first 512 bytes to determine if it is viewable, to avoid the
embarrassing scenario where we display a bunch of binary garbled characters
on the page.  Granted, my code does open the file one additional time in the
markup view.  I'd prefer it if FileContentsPipe could be modified so that we
could open it once and check the first 512 bytes for that test but then
still reset and call readlines again on the already open file.

Do you think any differently about it now?  :-)

JJ




On Thu, Nov 13, 2008 at 3:59 PM, C. Michael Pilato <[email protected]>wrote:

> JJ wrote:
> > In any event, the templates need some way of telling if the file is
> > binary or text (i.e. something other than prefer_markup, since
> > prefer_markup could then be set for text files or images) so they don't
> > allow diffs or other things that don't make sense for binary files.
>
> I understand where you're coming from, but I'm concerned about the leanings
> of the cost/benefit ratio.  You're talking about adding significant
> processing overhead to avoid the display of a link which isn't necessarily
> going to be followed anyway (especially if the user is smart enough to know
> that clicking "view diffs" when looking at a JPEG is not likely to be
> productive), and which usually leads to relatively quick and painless
> "Sorry, can't do that" errors if clicked.  In other words, penalizing all
> viewers for the benefit of few.
>
> I was with you for the most part on simply removing images from the list of
> things that prefer_markup (need to think through that in full, including
> compatibility ramifications, before fully agreeing).  But the general
> problem of MIME types not being fully descriptive enough to answer the "is
> this human-readable?" question is a problem that exists *everywhere*, not
> just in ViewVC.
>
> --
> C. Michael Pilato <[email protected]>
>  CollabNet   <>   www.collab.net   <>   Distributed Development On Demand
>
>