[Rt-commit] rt branch, 4.0/escape-quotes-in-search-format, created. rt-4.0.18-2-gf851251

Alex Vandiver alexmv at bestpractical.com
Thu Oct 31 19:07:12 EDT 2013


The branch, 4.0/escape-quotes-in-search-format has been created
        at  f8512519102264bdd5a049a8b1523bffeec14824 (commit)

- Log -----------------------------------------------------------------
commit 996420dbc41bf27528ad3af55d1398c231ba2b8e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Oct 31 19:01:38 2013 -0400

    Return unescaped values from ParseFormat
    
    This ensures that callsites need not care about any escaping that may
    have existed in the format; they instead recieve the completely parsed
    values.

diff --git a/share/html/Elements/CollectionAsTable/ParseFormat b/share/html/Elements/CollectionAsTable/ParseFormat
index e003704..658a2da 100644
--- a/share/html/Elements/CollectionAsTable/ParseFormat
+++ b/share/html/Elements/CollectionAsTable/ParseFormat
@@ -59,6 +59,7 @@ while ($Format =~ /($RE{delimited}{-delim=>qq{\'"}}|[{}\w.]+)/go) {
     if ($col =~ /^$RE{quoted}$/o) {
         substr($col,0,1) = "";
         substr($col,-1,1) = "";
+        $col =~ s/\\(.)/$1/g;
     }
 
     my $colref = { };

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

    Handle single quotes correctly in format strings
    
    Previously, BuildFormatString used a naive/buggy format parser, e.g.  it
    can't handle commas in fields, and misparsed strings like "__Foo__ or
    __Bar__" and "__CF.{Some Thing Here}__".  It has now been replaced by
    our standard ParseFormat component.
    
    Additionally, ensure that the values returned from ParseFormat are the
    fully parsed values, which includes performing all unescaping.  This
    simplifies round-tripping.

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 );
 }
 

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


More information about the Rt-commit mailing list