cvsweb and binary files

daniel.wallner at bredband.net daniel.wallner at bredband.net
Wed May 28 01:19:50 PDT 2003


We are using cvsweb to browse our cvs repository where we have both
text based design files and binary documents.
For text files cvsweb behaves acceptable but for binary documents
the default behavior is a bit weird.
This is mainly due to that the default mime type is text for nearly
all files, while this is fine for Internet Explorer that seems to
ignore the type, Netscape just displays garbage.
But there are also some bugs related to this.
There is a simple way to make the default mime types correct,
either comment out the "*" line in %MTYPES or add the types you need.
Since the gain of the "*" is negligible, I don't think it should be
in the default configuration due to all the trouble it causes.
However, if you remove the "*" line from %MTYPES it still doesn't solve
the problems entirely.

These problems exists in both version 1.149 and 1.119.2.8,
although the line numbers refer to 1.149.

1: At line 896 mimetype and defaultViewable are not
defined correctly, adding lines:

895a896,897
>       $mimetype = &getMimeTypeFromSuffix($file);
>       $defaultViewable  = $allow_markup && viewable($mimetype);

fixes the problem although a better solution would be to remove
these ugly global variables.


2: In getMimeTypeFromSuffix the $mimetype variable can sometimes be
uninitialized, adding the line:

1494a1497
>     $mimetype = "";

fixes that problem. Although if the mime_types variable doesn't point
to a valid file $mimetype can still be used uninitialized.
There should be a check for this. Adding the line:

1509c1512
<   if (!($mimetype =~ /\S\/\S/)) {
---
>   if (!$mimetype || !($mimetype =~ /\S\/\S/)) {

removes the error message but it would be better to add a check
if the file exists and a proper error message.


3: In cvswebMarkup the code for viewing PDFs is wrong.
Changing the lines:

1896c1899
<     printf '<embed src="%s" width="100%%"><br>',
hrefquote("$url$barequery");
---
>     printf '<embed src="%s" width="100%%" height="100%%"><br>',
hrefquote("$url$barequery");

makes it possible to view PDFs in something else than thumbnail size.


4: Although this is not a bug, printLog behaves a bit strange when
the $mimetype variable is set correctly. When $mimetype incorrectly
is set to text for nearly all files the download link will always be
displayed separately and the revision number will always be the view
link.
If $mimetype is set correctly the behaviour will change depending
on if cvsweb thinks that it is possible to view the file or not.
This can be confusing enough for some people to wonder how to download
files when the download link isn't displayed verbatim.
I think it would be better if the download and view links were always
displayed separately.
Commenting or removing these lines fixes the problem:

2582c2585
<     if ($defaultViewable) {
---
> #    if ($defaultViewable) {
2586c2589
<     }
---
> #    }
2594c2597
<     if (!$defaultViewable) {
---
> #    if (!$defaultViewable) {
2598c2601
<     }

The download link itself can also cause problems, and it is different than the
link in the revision number. The revision number link always work, the
download link doesn't. Netscape gets very confused when the mime
type is set to something it doesn't recognize. So it would be better if
the download link was changed to the same as the revision number link.

Regards,
Daniel Wallner




More information about the freebsd-cvsweb mailing list