Mercurial > pub > Impl
changeset 144:b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
minor speed improvements to the object CTOR caching
Added support for a secure processing (and 'laundering' ) a CGI parameters
Many minor fixes
author | wizard |
---|---|
date | Tue, 13 Jul 2010 02:05:38 +0400 |
parents | d9dd3500ead3 |
children | bd10093bb122 |
files | Lib/IMPL/DOM/Transform/PostToDOM.pm Lib/IMPL/Object/Abstract.pm Lib/IMPL/Object/Singleton.pm Lib/IMPL/Security/Role.pm Lib/IMPL/Web/Application/Action.pm Lib/IMPL/Web/Application/ControllerUnit.pm Lib/IMPL/Web/QueryHandler/PageFormat.pm Lib/IMPL/Web/TT/Form.pm |
diffstat | 8 files changed, 43 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Transform/PostToDOM.pm Thu Jul 08 23:46:49 2010 +0400 +++ b/Lib/IMPL/DOM/Transform/PostToDOM.pm Tue Jul 13 02:05:38 2010 +0400 @@ -71,7 +71,7 @@ $prefix = qr/$prefix/; foreach my $param (grep $_=~/$prefix/, $query->param()) { - my $value = $query->param($param); + my $value = $query->param($param) or next; my @parts = split /\//,$param;
--- a/Lib/IMPL/Object/Abstract.pm Thu Jul 08 23:46:49 2010 +0400 +++ b/Lib/IMPL/Object/Abstract.pm Tue Jul 13 02:05:38 2010 +0400 @@ -29,14 +29,14 @@ push @sequence, sub { my $this = shift; $this->$_($mapper->(@_)) foreach @$superSequence; - }; + } if @$superSequence; } } else { warn "Unsupported mapper type, in '$class' for the super class '$super'" if $mapper; push @sequence, sub { my $this = shift; $this->$_() foreach @$superSequence; - }; + } if @$superSequence; } }
--- a/Lib/IMPL/Object/Singleton.pm Thu Jul 08 23:46:49 2010 +0400 +++ b/Lib/IMPL/Object/Singleton.pm Tue Jul 13 02:05:38 2010 +0400 @@ -10,9 +10,7 @@ } sub instance { - my $self = shift; - - $instances{$_[0]}; + $instances{$_[0]} } 1;
--- a/Lib/IMPL/Security/Role.pm Thu Jul 08 23:46:49 2010 +0400 +++ b/Lib/IMPL/Security/Role.pm Tue Jul 13 02:05:38 2010 +0400 @@ -12,8 +12,8 @@ sub CTOR { my ($this,$name,$parentRoles) = @_; - $this->roleName($name); - $this->parentRoles($parentRoles); + $this->roleName($name) if $name; + $this->parentRoles($parentRoles) if $parentRoles; } sub Satisfy {
--- a/Lib/IMPL/Web/Application/Action.pm Thu Jul 08 23:46:49 2010 +0400 +++ b/Lib/IMPL/Web/Application/Action.pm Tue Jul 13 02:05:38 2010 +0400 @@ -81,6 +81,36 @@ } +sub cookie { + my ($this,$name,$rx) = @_; + + $this->_launder( $this->query->cookie($name), $rx ); +} + +sub param { + my ($this,$name,$rx) = @_; + + $this->_launder( $this->query->param($name), $rx ); +} + +sub _launder { + my ($this,$value,$rx) = @_; + + if ( $value ) { + if ($rx) { + if ( my @result = ($value =~ m/$rx/) ) { + return @result > 1 ? \@result : \@result; + } else { + return undef; + } + } else { + return $value; + } + } else { + return undef; + } +} + 1; __END__
--- a/Lib/IMPL/Web/Application/ControllerUnit.pm Thu Jul 08 23:46:49 2010 +0400 +++ b/Lib/IMPL/Web/Application/ControllerUnit.pm Tue Jul 13 02:05:38 2010 +0400 @@ -20,6 +20,7 @@ public property action => prop_get | owner_set; public property application => prop_get | owner_set; public property query => prop_get | owner_set; + public property response => prop_get | owner_set; public property formData => prop_get | owner_set; public property formSchema => prop_get | owner_set; public property formErrors => prop_get | owner_set; @@ -35,6 +36,7 @@ $this->action($action); $this->application($action->application); $this->query($action->query); + $this->response($action->response); $this->$_($args->{$_}) foreach qw(formData formSchema formErrors); } @@ -111,7 +113,7 @@ if ( $param =~ /^::(\w+)$/ and $publicProps{$1}) { return $this->$1(); } else { - return $this->query->param($param); + return scalar($this->query->param($param)); } }
--- a/Lib/IMPL/Web/QueryHandler/PageFormat.pm Thu Jul 08 23:46:49 2010 +0400 +++ b/Lib/IMPL/Web/QueryHandler/PageFormat.pm Tue Jul 13 02:05:38 2010 +0400 @@ -72,6 +72,7 @@ $doc->LoadFile ( File::Spec->catfile($this->templatesBase,@path), $this->templatesCharset, $this->templatesBase ); $doc->AddVar( result => $nextHandler->() ); + $doc->AddVar( action => $action ); $doc->AddVar( app => $action->application ); $doc->AddVar( absoluteUrl => sub { join '/', @root, $_[0] } );
--- a/Lib/IMPL/Web/TT/Form.pm Thu Jul 08 23:46:49 2010 +0400 +++ b/Lib/IMPL/Web/TT/Form.pm Tue Jul 13 02:05:38 2010 +0400 @@ -61,7 +61,9 @@ my @errors; if ($node) { - @errors = grep { ( $_->Node || $_->Parent) == $node } @{$this->errors}; + @errors = grep { ($_->Node || $_->Parent) == $node } @{$this->errors}; + } else { + @errors = grep $_->Schema == $sourceSchema, @{$this->errors}; } return {