[Rt-commit] rt branch, 4.0/search-titlebox-fix, created. rt-4.0.0-409-geca30fc

? sunnavy sunnavy at bestpractical.com
Thu May 19 06:16:39 EDT 2011


The branch, 4.0/search-titlebox-fix has been created
        at  eca30fce0bd6b63156d8161aea7cd3393979e0ec (commit)

- Log -----------------------------------------------------------------
commit 0eeb67e466a38cf5436d22e99e933cdd3f1ed0d6
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu May 19 16:37:36 2011 +0800

    tweak titlebox of search: escape "[" and "]" except in [_1] automatically
    
    this allows literal "[" and "]" in search's description.

diff --git a/share/html/Elements/ShowSearch b/share/html/Elements/ShowSearch
index cd6d6a8..8ee267f 100644
--- a/share/html/Elements/ShowSearch
+++ b/share/html/Elements/ShowSearch
@@ -46,7 +46,7 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <&|/Widgets/TitleBox,
-    title => loc($search->Description, $ProcessedSearchArg->{'Rows'}),
+    title => loc($desc, $ProcessedSearchArg->{'Rows'}),
     title_href => $query_link_url.$QueryString,
     titleright => $customize ? loc('Edit') : '',
     titleright_href => $customize,
@@ -142,6 +142,13 @@ foreach ( $SearchArg, $ProcessedSearchArg ) {
 
 my $QueryString = '?' . $m->comp( '/Elements/QueryString', %$SearchArg );
 
+my $desc = $search->Description;
+
+# we only use [_1] here, let's escape other "[" and "]" unless they are
+# escaped already
+$desc =~ s/(?<!~)\[(?!_1\])/~[/g;
+$desc =~ s/(?<!~)(?<!\[_1)\]/~]/g;
+
 </%init>
 <%ARGS>
 $Name           => undef

commit eca30fce0bd6b63156d8161aea7cd3393979e0ec
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu May 19 17:32:24 2011 +0800

    search titlebox test with "[" and "]" in description

diff --git a/t/web/custom_frontpage.t b/t/web/custom_frontpage.t
index 893ddd2..43c5f6e 100644
--- a/t/web/custom_frontpage.t
+++ b/t/web/custom_frontpage.t
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 use strict;
 
-use RT::Test tests => 9;
+use RT::Test tests => 12;
 my ($baseurl, $m) = RT::Test->started_ok;
 
 my $url = $m->rt_base_url;
@@ -59,3 +59,32 @@ $m->form_name ('SelectionBox-body');
 #$m->click_button (name => 'body-Save');
 $m->get ( $url );
 $m->content_contains('highest priority tickets', 'adds them back');
+
+
+#create a saved search with special chars
+$m->get( $url . "Search/Build.html" );
+$m->form_name('BuildQuery');
+$m->field( "ValueOfAttachment"      => 'stupid' );
+$m->field( "SavedSearchDescription" => 'special chars [test] [_1] ~[_1~]' );
+$m->click_button( name => 'SavedSearchSave' );
+my ($name) = $m->content =~ /value="(RT::User-\d+-SavedSearch-\d+)"/;
+ok( $name, 'saved search name' );
+$m->get( $url . 'Prefs/MyRT.html' );
+$m->content_contains( 'special chars [test] [_1] ~[_1~]',
+    'saved search listed in rt at a glance items' );
+
+$m->get( $url . 'Prefs/MyRT.html' );
+$m->form_name('SelectionBox-body');
+$m->field(
+    'body-Available' => [
+        'component-QuickCreate',
+        'system-Unowned Tickets',
+        'system-My Tickets',
+        'saved-' . $name,
+    ]
+);
+$m->click_button( name => 'add' );
+
+$m->get($url);
+$m->content_like( qr/special chars \[test\] \d+ \[_1\]/,
+    'special chars in titlebox' );

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


More information about the Rt-commit mailing list