From c68c65a5048159c4be99a12b7aaf1833745d87a5 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 10 Feb 2006 21:18:13 +0000 Subject: [PATCH] forward port of newline/cr bug fix --- docs/changelog/6.x.x.txt | 1 + lib/WebGUI/Form/Combo.pm | 4 +++- lib/WebGUI/Form/Text.pm | 19 +++++++++++++++++++ lib/WebGUI/Form/Url.pm | 1 + lib/WebGUI/Form/Zipcode.pm | 1 + 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 99858c547..3d047d01d 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -41,6 +41,7 @@ - fixed a bug where uploaded files and images did not get the right .wgaccess file (Martin Kamerbeek / Procolix) - fix [ 1429349 ] Invalid HTML returned by func=manageAssets + - fix [ 1429348 ] Textboxes need to filter CR/LF 6.8.5 - fix [ 1396957 ] Insufficient privileges check on the DataForm diff --git a/lib/WebGUI/Form/Combo.pm b/lib/WebGUI/Form/Combo.pm index 2dd3756a5..65a50d453 100644 --- a/lib/WebGUI/Form/Combo.pm +++ b/lib/WebGUI/Form/Combo.pm @@ -87,7 +87,9 @@ the list. sub getValueFromPost { my $self = shift; if ($self->session->form->param($self->get("name")."_new")) { - return $self->session->form->param($self->get("name")."_new"); + my $formValue = $self->session->form->param($self->get("name")."_new"); + $formValue =~ tr/\r\n//d; + return $formValue; } return $self->SUPER::getValueFromPost; } diff --git a/lib/WebGUI/Form/Text.pm b/lib/WebGUI/Form/Text.pm index eed96ca0d..44cc9349f 100644 --- a/lib/WebGUI/Form/Text.pm +++ b/lib/WebGUI/Form/Text.pm @@ -84,6 +84,25 @@ sub definition { #------------------------------------------------------------------- +=head2 getValueFromPost ( ) + +Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead. Strip newlines/carriage returns from the value. + +=cut + +sub getValueFromPost { + my $self = shift; + my $formValue = $session{req}->param($self->{name}); + if (defined $formValue) { + $formValue =~ tr/\r\n//d; + return $formValue; + } else { + return $self->{defaultValue}; + } +} + +#------------------------------------------------------------------- + =head2 toHtml ( ) Renders an input tag of type text. diff --git a/lib/WebGUI/Form/Url.pm b/lib/WebGUI/Form/Url.pm index 988209d6b..c91211e15 100644 --- a/lib/WebGUI/Form/Url.pm +++ b/lib/WebGUI/Form/Url.pm @@ -86,6 +86,7 @@ Parses the posted value and tries to make corrections if necessary. sub getValueFromPost { my $self = shift; my $value = $self->session->form->param($self->get("name")); + $value =~ tr/\r\n//d; if ($value =~ /mailto:/) { return $value; } elsif ($value =~ /^([A-Z0-9]+[._+-]?){1,}([A-Z0-9]+[_+-]?)+\@(([A-Z0-9]+[._-]?){1,}[A-Z0-9]+\.){1,}[A-Z]{2,4}$/i) { diff --git a/lib/WebGUI/Form/Zipcode.pm b/lib/WebGUI/Form/Zipcode.pm index 968052d98..e3d83922c 100644 --- a/lib/WebGUI/Form/Zipcode.pm +++ b/lib/WebGUI/Form/Zipcode.pm @@ -86,6 +86,7 @@ Returns a validated form post result. If the result does not pass validation, it sub getValueFromPost { my $self = shift; my $value = $self->session->form->param($self->get("name")); + $value =~ tr/\r\n//d; if ($value =~ /^[A-Z\d\s\-]+$/) { return $value; }