• 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.

Item6308: viewfile adds trailing newline to attachments

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Normal Closed   patch  

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

After debugging why pptx files were not able to be opened after passing through our TWiki installation, I finally noticed that there was one extra byte on the file after downloading it from our TWiki.

TWiki was adding a trailing newline to the file via the 'viewfile' script. Apparently all our file formats could handle it except pptx.

I found a HERE document which wasn't do anything to deal with the implied trailing newline, as described here: http://www.stonehenge.com/merlyn/UnixReview/col12.html

Patch follows:

--- lib/TWiki/UI/View.pm.orig   2009-03-09 18:40:05.000000000 -0700
+++ lib/TWiki/UI/View.pm        2009-08-18 20:14:14.000000000 -0700
@@ -421,15 +421,15 @@
     my $fileContent = $session->{store}->readAttachment(
         $session->{user}, $webName, $topic, $fileName, $rev );
 
     my $type = _suffixToMimeType( $session, $fileName );
     my $length =  length( $fileContent );
     my $dispo = 'inline;filename='.$fileName;
 
-    print <<HERE;
+    print substr(<<HERE,0,-1);
 Content-type: $type
 Content-length: $length
 Content-Disposition: $dispo
 
 $fileContent
 HERE
 }

ItemTemplate
Summary viewfile adds trailing newline to attachments
ReportedBy TWiki:Main.BuckGolemon
Codebase

SVN Range TWiki-5.0.0, Sat, 18 Apr 2009, build 18024
AppliesTo Engine
Component

Priority Normal
CurrentState Closed
WaitingFor

Checkins

TargetRelease patch
ReleasedIn

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r3 - 2009-09-02 - SopanShewale
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback