diff options
author | Ivan Kohler <ivan@freeside.biz> | 2013-06-04 00:16:28 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2013-06-04 00:16:28 -0700 |
commit | 7588a4ac90a9b07c08a3107cd1107d773be1c991 (patch) | |
tree | 55b8bedb5f899e705da0ba7f608267943bf89e94 /rt/lib/RT/SavedSearch.pm | |
parent | 98d2b25256055abb0dfcb9f586b434474fa97afd (diff) |
RT 4.0.13
Diffstat (limited to 'rt/lib/RT/SavedSearch.pm')
-rw-r--r-- | rt/lib/RT/SavedSearch.pm | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/rt/lib/RT/SavedSearch.pm b/rt/lib/RT/SavedSearch.pm index f7695d6f0..7c4df8b76 100644 --- a/rt/lib/RT/SavedSearch.pm +++ b/rt/lib/RT/SavedSearch.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -77,7 +77,7 @@ An object of this class is called "search" =cut -sub ObjectName { "search" } +sub ObjectName { "search" } # loc sub PostLoad { my $self = shift; @@ -115,6 +115,28 @@ sub UpdateAttribute { return ($status, $msg); } +=head2 RT::SavedSearch->EscapeDescription STRING + +This is a class method because system-level saved searches aren't true +C<RT::SavedSearch> objects but direct C<RT::Attribute> objects. + +Returns C<STRING> with all square brackets except those in C<[_1]> escaped, +ready for passing as the first argument to C<loc()>. + +=cut + +sub EscapeDescription { + my $self = shift; + my $desc = shift; + if ($desc) { + # We only use [_1] in saved search descriptions, so let's escape other "[" + # and "]" unless they are escaped already. + $desc =~ s/(?<!~)\[(?!_1\])/~[/g; + $desc =~ s/(?<!~)(?<!\[_1)\]/~]/g; + } + return $desc; +} + =head2 Type Returns the type of this search, e.g. 'Ticket'. Useful for denoting the |