# HG changeset patch # User wizard # Date 1278972338 -14400 # Node ID b56ebc31bf1858492074625dd155ed07fec51b69 # Parent d9dd3500ead3eea53850f94839c991f4b69fdea9 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 diff -r d9dd3500ead3 -r b56ebc31bf18 Lib/IMPL/DOM/Transform/PostToDOM.pm --- 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; diff -r d9dd3500ead3 -r b56ebc31bf18 Lib/IMPL/Object/Abstract.pm --- 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; } } diff -r d9dd3500ead3 -r b56ebc31bf18 Lib/IMPL/Object/Singleton.pm --- 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; diff -r d9dd3500ead3 -r b56ebc31bf18 Lib/IMPL/Security/Role.pm --- 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 { diff -r d9dd3500ead3 -r b56ebc31bf18 Lib/IMPL/Web/Application/Action.pm --- 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__ diff -r d9dd3500ead3 -r b56ebc31bf18 Lib/IMPL/Web/Application/ControllerUnit.pm --- 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)); } } diff -r d9dd3500ead3 -r b56ebc31bf18 Lib/IMPL/Web/QueryHandler/PageFormat.pm --- 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] } ); diff -r d9dd3500ead3 -r b56ebc31bf18 Lib/IMPL/Web/TT/Form.pm --- 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 {