diff Lib/IMPL/Web/Application/Action.pm @ 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 9f5795a10939
children 60fd224f3e3c
line wrap: on
line diff
--- 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__