Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item13897: Replaced Error::Simple with Foswiki::Exception::Fatal
- Foswiki::App `user' attribute was decalred using unneeded and
non-existant builder.
  • Loading branch information
vrurg committed Aug 12, 2016
1 parent 1302781 commit 45c4131
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
2 changes: 0 additions & 2 deletions core/lib/Foswiki/App.pm
Expand Up @@ -255,10 +255,8 @@ has remoteUser => (
);
has user => (
is => 'rw',
lazy => 1,
clearer => 1,
predicate => 1,
builder => '_prepareUser',
);
has users => (
is => 'rw',
Expand Down
4 changes: 2 additions & 2 deletions core/lib/Foswiki/LoginManager.pm
Expand Up @@ -120,7 +120,7 @@ sub makeLoginManager {
}
$use .= '; use CGI::Cookie ()';
eval $use;
throw Error::Simple($@) if $@;
Foswiki::Exception::Fatal->throw( text => $@ ) if $@;
if ( $req->https() ) {
$sessionname = 'SFOSWIKISID';
}
Expand Down Expand Up @@ -910,7 +910,7 @@ sub userLoggedIn {

# Don't make a session for the guest user.
unless ( $authUser eq $Foswiki::cfg{DefaultUserLogin}
&& !$this->_guestSessions
&& !$this->_guestSessions
&& !$app->inContext('sessionRequired') )

{
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Meta.pm
Expand Up @@ -3209,7 +3209,7 @@ time (see perldoc -f -X for more information)
Other standard Perl file tests may also be supported on some store
implementations, but cannot be relied on.
Errors will be signalled by an Error::Simple exception.
Errors will be signalled by an exception.
=cut

Expand Down
3 changes: 2 additions & 1 deletion core/lib/Foswiki/Plugins.pm
Expand Up @@ -162,7 +162,8 @@ sub preload {
$pn,
sub {
my $pn = shift;
throw Error::Simple('Bad debugenableplugins')
Foswiki::Exception::Fatal->throw(
text => 'Bad debugenableplugins' )
unless $pn =~ m/^[a-zA-Z0-9_]+$/;
return $pn;
}
Expand Down
42 changes: 26 additions & 16 deletions core/lib/Foswiki/Sandbox.pm
Expand Up @@ -239,10 +239,12 @@ sub _cleanUpFilePath {
$component ||= '';
next if $component eq '.';
if ( $component eq '..' ) {
throw Error::Simple( 'relative path in filename ' . $string );
Foswiki::Exception::Fatal->throw(
text => 'relative path in filename ' . $string );
}
elsif ( $component =~ m/$Foswiki::cfg{AttachmentNameFilter}/ ) {
throw Error::Simple( 'illegal characters in file name component "'
Foswiki::Exception::Fatal->throw(
text => 'illegal characters in file name component "'
. $component
. '" of filename '
. $string );
Expand Down Expand Up @@ -374,7 +376,8 @@ sub _buildCommandLine {
# implicit untaint of template OK
my ( $p, $flag ) = ( $1, $2 );
if ( !exists $params{$p} ) {
throw Error::Simple( 'unknown parameter name ' . $p );
Foswiki::Exception::Fatal->throw(
text => 'unknown parameter name ' . $p );
}
my $type = ref $params{$p};
my @params;
Expand All @@ -385,7 +388,8 @@ sub _buildCommandLine {
@params = @{ $params{$p} };
}
else {
throw Error::Simple( $type . ' reference passed in ' . $p );
Foswiki::Exception::Fatal->throw(
text => $type . ' reference passed in ' . $p );
}

for my $param (@params) {
Expand All @@ -411,8 +415,8 @@ sub _buildCommandLine {
push @targs, $1;
}
else {
throw Error::Simple(
"invalid number argument '$param' $t");
Foswiki::Exception::Fatal->throw(
text => "invalid number argument '$param' $t" );
}
}
elsif ( $flag eq 'S' ) {
Expand All @@ -423,8 +427,8 @@ sub _buildCommandLine {
push @targs, untaintUnchecked($param);
}
else {
throw Error::Simple(
"invalid string argument '$param' $t");
Foswiki::Exception::Fatal->throw(
text => "invalid string argument '$param' $t" );
}
}
elsif ( $flag eq 'D' ) {
Expand All @@ -436,12 +440,13 @@ sub _buildCommandLine {
push @targs, $1;
}
else {
throw Error::Simple(
"invalid date argument '$param' $t");
Foswiki::Exception::Fatal->throw(
text => "invalid date argument '$param' $t" );
}
}
else {
throw Error::Simple( 'illegal flag in ' . $t );
Foswiki::Exception::Fatal->throw(
text => 'illegal flag in ' . $t );
}
}
}
Expand Down Expand Up @@ -565,7 +570,8 @@ sub sysCommand {

my $pid = open( $handle, '-|' );

throw Error::Simple( 'open of pipe failed: ' . $! ) unless defined $pid;
Foswiki::Exception::Fatal->throw( text => 'open of pipe failed: ' . $! )
unless defined $pid;

if ($pid) {

Expand All @@ -575,7 +581,8 @@ sub sysCommand {
close $handle;
$exit = ( $? >> 8 );
if ( $exit == $key && $data =~ m/$key: (.*)/ ) {
throw Error::Simple("exec of $template failed: $1");
Foswiki::Exception::Fatal->throw(
text => "exec of $template failed: $1" );
}
}
else {
Expand Down Expand Up @@ -603,10 +610,12 @@ sub sysCommand {
my $writeHandle;

pipe( $readHandle, $writeHandle )
|| throw Error::Simple( 'could not create pipe: ' . $! );
|| Foswiki::Exception::Fatal->throw(
text => 'could not create pipe: ' . $! );

my $pid = fork();
throw Error::Simple( 'fork() failed: ' . $! ) unless defined($pid);
Foswiki::Exception::Fatal->throw( text => 'fork() failed: ' . $! )
unless defined($pid);

if ($pid) {

Expand All @@ -620,7 +629,8 @@ sub sysCommand {
$pid = wait; # wait for child process so we can get exit status
$exit = ( $? >> 8 );
if ( $exit == $key && $data =~ m/$key: (.*)/ ) {
throw Error::Simple( 'exec failed: ' . $1 );
Foswiki::Exception::Fatal->throw(
text => 'exec failed: ' . $1 );
}

}
Expand Down

0 comments on commit 45c4131

Please sign in to comment.