Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item13897: Brought the configure action back to some kind of life.
Mostly bug fixes.

- Dethroned _parent and _vobCache attributes of Foswiki::Configure::Item
class back to simple keys on attrs. Needed to have find/match methods work
properly.
  • Loading branch information
vrurg committed May 3, 2016
1 parent bbfbbf0 commit 1b1eab5
Show file tree
Hide file tree
Showing 21 changed files with 809 additions and 811 deletions.
16 changes: 8 additions & 8 deletions JsonRpcContrib/lib/Foswiki/Contrib/JsonRpcContrib.pm
Expand Up @@ -10,14 +10,14 @@ use Moo;
use namespace::clean;
extends qw(Foswiki::UI);

BEGIN {
# Backwards compatibility for Foswiki 1.1.x
unless ( Foswiki::Request->can('multi_param') ) {
no warnings 'redefine';
*Foswiki::Request::multi_param = \&Foswiki::Request::param;
use warnings 'redefine';
}
}
#BEGIN {
# # Backwards compatibility for Foswiki 1.1.x
# unless ( Foswiki::Request->can('multi_param') ) {
# no warnings 'redefine';
# *Foswiki::Request::multi_param = \&Foswiki::Request::param;
# use warnings 'redefine';
# }
#}

=begin TML
Expand Down
2 changes: 1 addition & 1 deletion core/lib/AssertOn.pm
Expand Up @@ -5,8 +5,8 @@

use strict;
use locale; # so result of lc() is tainted
use Foswiki::Exception;

require Foswiki::Exception;
our $DIRTY = lc('x'); # Used in TAINT
our $soft = 0;

Expand Down
189 changes: 90 additions & 99 deletions core/lib/Foswiki.pm
Expand Up @@ -94,106 +94,97 @@ our $inUnitTestMode = 0;

use Try::Tiny;

use Moo;
use namespace::clean;
extends qw( Foswiki::Object );
#use Moo;
#use namespace::clean;
#extends qw( Foswiki::Object );

use Assert;
use Exporter qw(import);
our @EXPORT_OK = qw(%regex urlEncode urlDecode make_params load_package);
our @EXPORT_OK =
qw(%regex urlEncode urlDecode make_params load_package load_class);

sub SINGLE_SINGLETONS { 0 }
sub SINGLE_SINGLETONS_TRACE { 0 }

has digester => (
is => 'ro',
lazy => 1,
clearer => 1,
default => sub { return Digest::MD5->new; },
);
has forms => (
is => 'ro',
lazy => 1,
clearer => 1,
default => sub { {} },
);

# Heap is to be used for data persistent over session lifetime.
# Usage: $sessiom->heap->{key} = <your data>;
has heap => (
is => 'rw',
clearer => 1,
lazy => 1,
default => sub { {} },
);
has net => (
is => 'ro',
lazy => 1,
clearer => 1,
predicate => 1,
default => sub {
load_package('Foswiki::Net');
return Foswiki::Net->new( session => $_[0] );
},
);
has remoteUser => (
is => 'rw',
clearer => 1,
);
has requestedWebName => ( is => 'rw', clearer => 1, );
has response => (
is => 'rw',
lazy => 1,
clearer => 1,
default => sub { return Foswiki::Response->new; },
);
has sandbox => (
is => 'ro',
default => 'Foswiki::Sandbox',
clearer => 1,
);
has scriptUrlPath => (
is => 'ro',
lazy => 1,
clearer => 1,
default => sub {
my $this = shift;
my $scriptUrlPath = $Foswiki::cfg{ScriptUrlPath};
my $url = $this->request->url;
if ( $Foswiki::cfg{GetScriptUrlFromCgi}
&& $url
&& $url =~ m{^[^:]*://[^/]*(.*)/.*$}
&& $1 )
{

# SMELL: this is a really dangerous hack. It will fail
# spectacularly with mod_perl.
# SMELL: why not just use $query->script_name?
# SMELL: unchecked implicit untaint?
$scriptUrlPath = $1;
}
return $scriptUrlPath;
},
);
has search => (
is => 'ro',
lazy => 1,
clearer => 1,
predicate => 1,
default => sub {
require Foswiki::Search;
return Foswiki::Search->new( session => $_[0] );
},
);
has topicName => (
is => 'rw',
clearer => 1,
);

has webName => (
is => 'rw',
clearer => 1,
);
#has digester => (
# is => 'ro',
# lazy => 1,
# clearer => 1,
# default => sub { return Digest::MD5->new; },
#);
#has forms => (
# is => 'ro',
# lazy => 1,
# clearer => 1,
# default => sub { {} },
#);
#
## Heap is to be used for data persistent over session lifetime.
## Usage: $sessiom->heap->{key} = <your data>;
#has heap => (
# is => 'rw',
# clearer => 1,
# lazy => 1,
# default => sub { {} },
#);
#has remoteUser => (
# is => 'rw',
# clearer => 1,
#);
#has requestedWebName => ( is => 'rw', clearer => 1, );
#has response => (
# is => 'rw',
# lazy => 1,
# clearer => 1,
# default => sub { return Foswiki::Response->new; },
#);
#has sandbox => (
# is => 'ro',
# default => 'Foswiki::Sandbox',
# clearer => 1,
#);
#has scriptUrlPath => (
# is => 'ro',
# lazy => 1,
# clearer => 1,
# default => sub {
# my $this = shift;
# my $scriptUrlPath = $Foswiki::cfg{ScriptUrlPath};
# my $url = $this->request->url;
# if ( $Foswiki::cfg{GetScriptUrlFromCgi}
# && $url
# && $url =~ m{^[^:]*://[^/]*(.*)/.*$}
# && $1 )
# {
#
# # SMELL: this is a really dangerous hack. It will fail
# # spectacularly with mod_perl.
# # SMELL: why not just use $query->script_name?
# # SMELL: unchecked implicit untaint?
# $scriptUrlPath = $1;
# }
# return $scriptUrlPath;
# },
#);
#has search => (
# is => 'ro',
# lazy => 1,
# clearer => 1,
# predicate => 1,
# default => sub {
# require Foswiki::Search;
# return Foswiki::Search->new( session => $_[0] );
# },
#);
#has topicName => (
# is => 'rw',
# clearer => 1,
#);
#
#has webName => (
# is => 'rw',
# clearer => 1,
#);

our @_newParameters = qw( user request context );

Expand Down Expand Up @@ -310,10 +301,10 @@ BEGIN {
use version 0.77; $VERSION = version->declare('v2.1.0');
$RELEASE = 'Foswiki-2.1.0';

if ( $Foswiki::cfg{UseLocale} ) {
require locale;
import locale();
}
#if ( $Foswiki::cfg{UseLocale} ) {
# require locale;
# import locale();
#}

# Set environment var FOSWIKI_NOTAINT to disable taint checks even
# if Taint::Runtime is installed
Expand Down Expand Up @@ -400,7 +391,7 @@ script run. Session objects do not persist between mod_perl runs.
=cut

around BUILDARGS => sub {
sub __deprecated_BUILDARGS {
my $orig = shift;

my $params = $orig->(@_);
Expand Down Expand Up @@ -487,7 +478,7 @@ around BUILDARGS => sub {
}

return $params;
};
}

sub BUILD {
my $this = shift;
Expand Down
13 changes: 10 additions & 3 deletions core/lib/Foswiki/AccessControlException.pm
Expand Up @@ -84,7 +84,8 @@ package Foswiki::AccessControlException;
use v5.14;

use Moo;
extends 'Foswiki::Exception';
use namespace::clean;
extends qw(Foswiki::Exception);

BEGIN {
if ( $Foswiki::cfg{UseLocale} ) {
Expand Down Expand Up @@ -127,10 +128,16 @@ Generate a summary string. This is mainly for debugging.
around stringify => sub {
my $orig = shift;
my $this = shift;
my $topic = $this->{topic}
my $topic = $this->topic
|| ''; # Access checks of Web objects causes uninitialized string errors
return
"AccessControlException: Access to $this->{mode} $this->{web}.$topic for $this->{user} is denied. $this->{reason}";
"AccessControlException: Access to "
. $this->mode . " "
. $this->web
. ".$topic for "
. $this->user
. " is denied. "
. $this->reason;
};

1;
Expand Down
25 changes: 16 additions & 9 deletions core/lib/Foswiki/App.pm
Expand Up @@ -15,16 +15,16 @@ use v5.14;
use constant TRACE_REQUEST => 0;

use Assert;
use Carp;
use Cwd;
use CGI;
use Try::Tiny;
use Storable qw(dclone);
use CGI ();
use Compress::Zlib ();
use Foswiki::Config ();
use Foswiki::Engine ();
use Foswiki::Templates ();
use Foswiki qw(load_package);
use Foswiki::Exception ();
use Foswiki qw(load_package load_class);

use Moo;
use namespace::clean;
Expand Down Expand Up @@ -62,7 +62,7 @@ has cache => (
if ( $cfg->data->{Cache}{Enabled}
&& $cfg->data->{Cache}{Implementation} )
{
eval "require " . $cfg->data->{Cache}{Implementation};
load_class( $cfg->data->{Cache}{Implementation} );
ASSERT( !$@, $@ ) if DEBUG;
return $this->create( $cfg->data->{Cache}{Implementation} );
}
Expand Down Expand Up @@ -123,6 +123,13 @@ has i18n => (
$_[0]->create('Foswiki::I18N');
},
);
has net => (
is => 'ro',
lazy => 1,
clearer => 1,
predicate => 1,
default => sub { return $_[0]->create('Foswiki::Net'); },
);
has plugins => (
is => 'rw',
lazy => 1,
Expand Down Expand Up @@ -382,12 +389,12 @@ sub run {
try {
local $SIG{__DIE__} = sub {

#Carp::cluck "die(" . $_[0] . ")";
# Somehow overriding of __DIE__ clashes with remote perl debugger in
# Komodo unless we die again instantly.
die $_[0] if (caller)[0] =~ /^DB::/;
Foswiki::Exception::Fatal->rethrow( $_[0] );
};
local $SIG{__WARN__} = sub {

#Carp::cluck "warn(" . $_[0] . ")";
Foswiki::Exception::Fatal->rethrow( $_[0] );
}
if DEBUG;
Expand Down Expand Up @@ -713,7 +720,7 @@ sub redirect {

return unless $this->request;

( $url, my $anchor ) = splitAnchorFromUrl($url);
( $url, my $anchor ) = Foswiki::splitAnchorFromUrl($url);

if ( $passthru && defined $this->request->method() ) {
my $existing = '';
Expand Down Expand Up @@ -752,7 +759,7 @@ sub redirect {
# prevent phishing by only allowing redirect to configured host
# do this check as late as possible to catch _any_ last minute hacks
# TODO: this should really use URI
if ( !_isRedirectSafe($url) ) {
if ( !Foswiki::_isRedirectSafe($url) ) {

# goto oops if URL is trying to take us somewhere dangerous
$url = $this->cfg->getScriptUrl(
Expand Down
5 changes: 3 additions & 2 deletions core/lib/Foswiki/AppObject.pm
Expand Up @@ -20,8 +20,9 @@ use namespace::clean;
extends qw(Foswiki::Object);

has app => (
is => 'ro',
weak_ref => 1,
is => 'ro',
predicate => 1,
weak_ref => 1,
isa => Foswiki::Object::isaCLASS( 'app', 'Foswiki::App', noUndef => 1, ),
required => 1,
);
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Aux/Holder.pm
Expand Up @@ -11,7 +11,7 @@ Auxiliary class.
package Foswiki::Aux::Holder;
use v5.14;

use Foswiki::Object ();
require Foswiki::Object;

use Moo;
use namespace::clean;
Expand Down
1 change: 0 additions & 1 deletion core/lib/Foswiki/Aux/Localize.pm
Expand Up @@ -43,7 +43,6 @@ class.
package Foswiki::Aux::Localize;
use v5.14;

use Foswiki::Object ();
use Foswiki::Aux::Holder ();

use Moo::Role;
Expand Down

0 comments on commit 1b1eab5

Please sign in to comment.