[Rt-commit] r5039 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Mon Apr 17 09:02:47 EDT 2006
Author: ruz
Date: Mon Apr 17 09:02:47 2006
New Revision: 5039
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm
Log:
r2387 at cubic-pc: cubic | 2006-04-17 16:51:55 +0400
* don't copy text in EncodeUTF8
** we shouldn't also turn on UTF-8 flag on any random scalar
* merge duplicated CF handling code
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 Mon Apr 17 09:02:47 2006
@@ -76,21 +76,16 @@
=cut
sub EscapeUTF8 {
- my $ref = shift;
- return unless defined $$ref;
- my $val = $$ref;
- use bytes;
- $val =~ s/&/&/g;
- $val =~ s/</</g;
- $val =~ s/>/>/g;
- $val =~ s/\(/(/g;
- $val =~ s/\)/)/g;
- $val =~ s/"/"/g;
- $val =~ s/'/'/g;
- $$ref = $val;
- Encode::_utf8_on($$ref);
-
+ my $ref = shift;
+ return unless defined $$ref;
+ $$ref =~ s/&/&/g;
+ $$ref =~ s/</</g;
+ $$ref =~ s/>/>/g;
+ $$ref =~ s/\(/(/g;
+ $$ref =~ s/\)/)/g;
+ $$ref =~ s/"/"/g;
+ $$ref =~ s/'/'/g;
}
# }}}
@@ -1158,14 +1153,13 @@
if ( ($CustomFieldObj->Type eq 'Freeform'
&& ! $CustomFieldObj->SingleValue) ||
$CustomFieldObj->Type =~ /text/i) {
- foreach my $val (@values) {
+ foreach my $val (grep defined, @values) {
$val =~ s/\r//g;
}
}
- if ( ( $arg =~ /-AddValue$/ ) || ( $arg =~ /-Value$/ ) ) {
- foreach my $value (@values) {
- next unless length($value);
+ if ( $arg =~ /-(Add|)Value$/ ) {
+ foreach my $value (grep defined && length, @values) {
my ( $val, $msg ) = $Object->AddCustomFieldValue(
Field => $cf,
Value => $value
@@ -1182,9 +1176,8 @@
);
push ( @results, $msg );
}
- elsif ( $arg =~ /-DeleteValues$/ ) {
- foreach my $value (@values) {
- next unless length($value);
+ elsif ( $arg =~ /-DeleteValue(Id|)s$/ ) {
+ foreach my $value (grep defined && length, @values) {
my ( $val, $msg ) = $Object->DeleteCustomFieldValue(
Field => $cf,
Value => $value
@@ -1192,22 +1185,11 @@
push ( @results, $msg );
}
}
- elsif ( $arg =~ /-DeleteValueIds$/ ) {
- foreach my $value (@values) {
- next unless length($value);
- my ( $val, $msg ) = $Object->DeleteCustomFieldValue(
- Field => $cf,
- ValueId => $value,
- );
- push ( @results, $msg );
- }
- }
elsif ( $arg =~ /-Values$/ and !$CustomFieldObj->Repeated) {
my $cf_values = $Object->CustomFieldValues($cf);
my %values_hash;
- foreach my $value (@values) {
- next unless length($value);
+ foreach my $value (grep defined && length, @values) {
# build up a hash of values that the new set has
$values_hash{$value} = 1;
More information about the Rt-commit
mailing list