• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item6387: Files attached to page are given an extra byte

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Normal Waiting for Feedback   n/a  

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


Files attached to twiki are coming back corrupted, with an extra newline character added to the end. Many programs are tolerant of this extra byte, but some (like Java) are not.

When we attach ZIP files to a wiki page, an extra byte is appended to the file at the end: 0x0A

-- TWiki:Main/SethPackham - 22 Jan 2010

Originally reported at TWiki:Support/SID-00726

-- TWiki:Main.PeterThoeny - 23 Jan 2010

This issue seems to be fixed in recent versions of the TWiki - kindly request you to try latest version of TWiki.

Please let me know if you want to stick to the old version - i can provide the patch here


-- TWiki:Main.SopanShewale - 05 Feb 2010

Could not recreate this - seems like its fixed - so changing the status.

-- TWiki:Main.SopanShewale - 16 Feb 2010

we also have the same problem. can you please provide the patch so that we can overcome this issue at the earliest.

-- TWiki:Main.GauravMittal - 09 Mar 2010

Peter, Can you please attach the Patch for this issue, so that i can install it as soon as possible. We are facing lot of issues because of this.

-- TWiki:Main.GauravMittal - 10 Mar 2010

Hi - please check the following:

sopan@laptop:~/twikireleases/twiki432/lib/TWiki/UI$ diff -u View.pm  ~sopan/twikireleases/twiki421/lib/TWiki/UI/View.pm --- View.pm   2009-09-02 18:59:23.000000000 +0530
+++ /home/sopan/twikireleases/twiki421/lib/TWiki/UI/View.pm   2008-08-04 03:43:32.000000000 +0530
@@ -430,35 +430,7 @@
     if( defined( $query->param( 'filename' ))) {
         $fileName = $query->param( 'filename' );
     } else {
-         # Ok file name is not comming from explicit query parameter
-         # Let us cook from @path
-         $fileName = pop( @path );
-         #Let us redefine web/topic - fix of Item5967
-        if( $fileName =~ /\.([^.]+)$/ ) {  #file has extension
-            my $suffix = $1;
-            my $presuffix = $fileName;
-            $presuffix  =~ s/\.$suffix$//;
-            $webName =~ s/$presuffix$//o;  #let us drop filename part from webName
-            $webName =~ s/\/$//o;
-            if ($webName =~ /\/([^\/]+)$/) {$topic = $1;} #topic name defined here
-            $webName =~ s/$topic$//o;
-            $webName =~ s/\/$//o;
-         } else {    #file does not have extension
-            $webName =~ s/$fileName$//o;  #let us drop the filename from webName
-            $webName =~ s/\/$//o;
-            if ($webName =~ /\/([^\/]+)$/) {$topic = $1;}  #topic name redefined here
-            $webName =~ s/$topic$//o;
-            $webName =~ s/\/$//o;
-        }
+        $fileName = pop( @path );
     if (!$fileName) {
         throw TWiki::OopsException( 'attention',
@@ -485,10 +457,14 @@
     my $type = _suffixToMimeType( $session, $fileName );
     my $length =  length( $fileContent );
     my $dispo = 'inline;filename='.$fileName;
-    print $query->header("-type"=>$type, "-Content-length"=>$length, "-Content-Disposition"=>$dispo,);
-    print $fileContent;
+    print <<HERE;
+Content-type: $type
+Content-length: $length
+Content-Disposition: $dispo
 sub _suffixToMimeType {

-- TWiki:Main.SopanShewale - 07 Apr 2010

Sopan, I'd be careful about removing the code if file name is part of extended view path. This is likely to break URLs like http://example.com/pub/Baseweb/Subweb/SomePage/somefile.doc

This bug shows up only on two installs. I suspect a bug in CGI Perl module.

Gaurav and Seth: What is the version of CGI do you have installed? Test on command line:

perl -e 'use CGI; print "$CGI::VERSION\n"'

Try upgrading your CGI module.

-- TWiki:Main.PeterThoeny - 07 Apr 2010

Hi Gaurav and Seth,

Please let us know the exact process: how you are noticing extra byte? are you downloading files via "viewfile"? (i have noticed extra byte in old versions while downloading via "viewfile")

or Are you downloading files via %PUBURL%/web/topic/attachment way?

Do you also see the extra bye when you login to twiki server, view attachment by going to pub/web/topic directory?

Please give us some more information

Thank you,

-- TWiki:Main.SopanShewale - 12 Apr 2010

Summary Files attached to page are given an extra byte
ReportedBy TWiki:Main.SethPackham
Codebase 4.2.1
SVN Range TWiki-5.0.0, Sat, 02 Jan 2010, build 18269
AppliesTo Engine

Priority Normal
CurrentState Waiting for Feedback


TargetRelease n/a

Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r10 - 2010-04-12 - SopanShewale
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback