--- bin/viewfile.orig 2005-08-10 15:03:48.000000000 +0200 +++ bin/viewfile 2005-08-10 15:15:36.000000000 +0200 @@ -37,9 +37,9 @@ my $theUrl = $query->url; my $theTopic = $query->param( 'topic' ); -my ( $topic, $webName ) = +my ( $topic, $webName, $scriptUrlPath, $userName ) = TWiki::initialize( $thePathInfo, $theRemoteUser, $theTopic, $theUrl, $query ); -TWiki::UI::Viewfile::view( $webName, $topic, $query ); +TWiki::UI::Viewfile::view( $webName, $topic, $userName, $query ); --- lib/TWiki/UI/Viewfile.pm.orig 2004-05-29 08:51:35.000000000 +0200 +++ lib/TWiki/UI/Viewfile.pm 2005-10-03 23:43:05.000000000 +0200 @@ -39,16 +39,22 @@ =cut sub view { - my ( $webName, $topic, $query ) = @_; + my ( $webName, $topic, $userName, $query ) = @_; my $fileName = $query->param( 'filename' ); my $rev = $query->param( 'rev' ) || ""; + $rev =~ s/r?1\.//o; # cut 'r' and major + # Fix for Codev.SecurityAlertExecuteCommandsWithRev + $rev = "" unless( $rev =~ s/^.*?([0-9]+).*$/$1/so ); return unless TWiki::UI::webExists( $webName, $topic ); + + if ( ! $rev ) { $rev = TWiki::Store::getRevisionNumber( $webName, $topic, $fileName ); }; - my $topRev = TWiki::Store::getRevisionNumber( $webName, $topic, $fileName ); - - if( ( $rev ) && ( $rev ne $topRev ) ) { + my $wikiUserName = &TWiki::userToWikiName( $userName ); + my $viewAccessOK = &TWiki::Func::checkAccessPermission( "view", $wikiUserName, undef , $topic, $webName ); + + if( $viewAccessOK ) { my $fileContent = TWiki::Store::readAttachmentVersion( $webName, $topic, $fileName, $rev ); if( $fileContent ) { my $mimeType = _suffixToMimeType( $fileName ); @@ -59,16 +65,10 @@ } else { # If no file content we'll try and show pub content, should there be a warning FIXME } - } - - # this should actually kick off a document conversion - # (.doc, .xls... to .html) and show the html file. - # Convert only if html file does not yet exist - # for now, show the original document: - - my $pubUrlPath = &TWiki::getPubUrlPath(); - my $host = $TWiki::urlHost; - TWiki::UI::redirect( "$host$pubUrlPath/$webName/$topic/$fileName" ); + } else { + TWiki::UI::oops( $webName, $topic, "accessview" ); + return; + }; } sub _suffixToMimeType {