[Rt-commit] r7121 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Fri Mar 2 14:35:59 EST 2007


Author: ruz
Date: Fri Mar  2 14:35:59 2007
New Revision: 7121

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm

Log:
 r4643 at cubic-pc:  cubic | 2007-03-02 22:31:56 +0300
 * fix processing of spaces in values of CFs with types when a user
   input things himself.
 ** upload is upload we do nothing with its content at all
 ** if argument is array then it contains multiple values and
    we don't parse text anymore
 ** even if an argument has only one value it can be text, so we
    don't parse the value if type of the CF matches 'text'
 ** in all other cases we use '\r*\n' as splitter and get list of
    values
 ** we delete leading and trailing spaces from all values


Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm	Fri Mar  2 14:35:59 2007
@@ -413,13 +413,16 @@
             } elsif ( $type =~ /text/i ) {
                 @values = ($ARGS{ $arg });
             } else {
-                @values = split /\n/, $ARGS{ $arg } || '';
+                @values = split /\r*\n/, $ARGS{ $arg } || '';
             }
-        
-            if ( $type =~ /text/i || $type eq 'Freeform' ) {
-                s/\r//g foreach grep defined, @values;
-            }
-            @values = grep defined && $_ ne '', @values;
+            @values = grep $_ ne '',
+                map {
+                    s/\r+\n/\n/g;
+                    s/^\s+//;
+                    s/\s+$//;
+                    $_;
+                }
+                grep defined, @values;
 
             $create_args{"CustomField-$cfid"} = \@values;
         }
@@ -1245,14 +1248,17 @@
         } elsif ( $cf_type =~ /text/i ) { # Both Text and Wikitext
             @values = ($args{'ARGS'}->{$arg});
         } else {
-            @values = split /\n/, $args{'ARGS'}->{ $arg } || '';
+            @values = split /\r*\n/, $args{'ARGS'}->{ $arg } || '';
         }
+        @values = grep $_ ne '',
+            map {
+                s/\r+\n/\n/g;
+                s/^\s+//;
+                s/\s+$//;
+                $_;
+            }
+            grep defined, @values;
         
-        if ( $cf_type eq 'Freeform' || $cf_type =~ /text/i ) {
-            s/\r//g foreach grep defined, @values;
-        }
-        @values = grep defined && $_ ne '', @values;
-
         if ( $arg eq 'AddValue' || $arg eq 'Value' ) {
             foreach my $value (@values) {
                 my ( $val, $msg ) = $args{'Object'}->AddCustomFieldValue(


More information about the Rt-commit mailing list