[Rt-commit] rt branch, 4.0/escape-quotes-in-search-format, updated. rt-4.0.18rc1-2-g34ff80b

? sunnavy sunnavy at bestpractical.com
Sun Oct 13 09:39:34 EDT 2013


The branch, 4.0/escape-quotes-in-search-format has been updated
       via  34ff80b97c9e1b8074a9acde5cbafa84ecda4079 (commit)
      from  420b0fe46bb5c61fb790f7dc31c6fd76e8c74a5e (commit)

Summary of changes:
 share/html/Search/Elements/BuildFormatString | 37 ++++++++++++----------------
 share/html/Search/Elements/EditFormat        |  8 ++----
 2 files changed, 18 insertions(+), 27 deletions(-)

- Log -----------------------------------------------------------------
commit 34ff80b97c9e1b8074a9acde5cbafa84ecda4079
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sun Oct 13 21:17:36 2013 +0800

    BuildFormatString is the more right place to handle escape stuff in EditFormat
    
    previously BuildFormatString use a naive/buggy format parser, e.g.  it can't
    handle commas in fields, misparse strings like "__Foo__ or __Bar__" and
    "__CF.{Some Thing Here}__". now it's been replaced by our standard ParseFormat
    component.

diff --git a/share/html/Search/Elements/BuildFormatString b/share/html/Search/Elements/BuildFormatString
index dc6a437..cd90161 100644
--- a/share/html/Search/Elements/BuildFormatString
+++ b/share/html/Search/Elements/BuildFormatString
@@ -119,22 +119,11 @@ $m->callback( Fields => \@fields, ARGSRef => \%ARGS );
 my ( @seen);
 
 $Format ||= RT->Config->Get('DefaultSearchResultFormat');
-my @format = split( /,\s*/, $Format );
+my @format = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $Format);
 foreach my $field (@format) {
-    my %column = ();
-    $field =~ s/'(.*)'/$1/;
-    my ( $prefix, $suffix );
-    if ( $field =~ m/(.*)__(.*)__(.*)/ ) {
-        $prefix = $1;
-        $suffix = $3;
-        $field  = $2;
-    }
-    $field = "<blank>" if !$field;
-    $column{Prefix} = $prefix;
-    $column{Suffix} = $suffix;
-    $field =~ s/\s*(.*)\s*/$1/;
-    $column{Column} = $field;
-    push @seen, \%column;
+    # "title" is for columns like NEWLINE, which doesn't have "attribute"
+    $field->{Column} = $field->{attribute} || $field->{title} || '<blank>';
+    push @seen, $field;
 }
 
 if ( $RemoveCol ) {
@@ -227,12 +216,18 @@ elsif ( $ColDown ) {
 my @format_string;
 foreach my $field (@seen) {
     next unless $field;
-    my $row = "'";
-    $row .= $field->{'Prefix'} if defined $field->{'Prefix'};
-    $row .= "__$field->{'Column'}__"
-      unless ( $field->{'Column'} eq "<blank>" );
-    $row .= $field->{'Suffix'} if defined $field->{'Suffix'};
-    $row .= "'";
+    my $row = "";
+    if ( $field->{'output'} ) {
+        $row = join '', @{$field->{'output'}};
+    }
+    else {
+        $row .= $field->{'Prefix'} if defined $field->{'Prefix'};
+        $row .= "__$field->{'Column'}__"
+          unless ( $field->{'Column'} eq "<blank>" );
+        $row .= $field->{'Suffix'} if defined $field->{'Suffix'};
+    }
+    $row =~ s!([\\'])!\\$1!g;
+    $row = "'$row'";
     push( @format_string, $row );
 }
 
diff --git a/share/html/Search/Elements/EditFormat b/share/html/Search/Elements/EditFormat
index e6a8c7f..c3491fc 100644
--- a/share/html/Search/Elements/EditFormat
+++ b/share/html/Search/Elements/EditFormat
@@ -59,9 +59,7 @@
 <td valign="top"><select size="6" name="SelectDisplayColumns" multiple="multiple">
 % my %seen;
 % foreach my $field ( grep !$seen{lc $_}++, @$AvailableColumns) {
-% my $value = $field;
-% $value =~ s!(['\\])!\\$1!g;
-<option value="<% $value %>"><% loc($field) %></option>
+<option value="<% $field %>"><% loc($field) %></option>
 % }
 </select></td>
 <td>
@@ -108,9 +106,7 @@
 <select size="4" name="CurrentDisplayColumns">
 % my $i=0;
 % foreach my $field ( @$CurrentFormat ) {
-% my $label = $field->{Column};
-% $label =~ s!\\(.)!$1!g;
-<option value="<% $i++ %>><% $field->{Column} %>"><% loc( $label ) %></option>
+<option value="<% $i++ %>><% $field->{Column} %>"><% loc( $field->{Column} ) %></option>
 % }
 </select>
 <br />

-----------------------------------------------------------------------


More information about the Rt-commit mailing list