[open-ils-commits] r20085 - trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Apr 14 14:18:41 EDT 2011


Author: dbs
Date: 2011-04-14 14:18:37 -0400 (Thu, 14 Apr 2011)
New Revision: 20085

Modified:
   trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm
Log:
Escape rather than filter SIMILAR TO metacharacters in patron crazy search

The filtering I introduced in r19983 was overly aggressive, and included
characters that weren't actually SIMILAR TO metacharacters. Instead, escape
each character, carefully going through the list of metacharacters listed at
http://www.postgresql.org/docs/8.4/interactive/functions-matching.html

Works for email addresses like "foo.bar+baz at example.com".


Modified: trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm	2011-04-14 17:58:52 UTC (rev 20084)
+++ trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm	2011-04-14 18:18:37 UTC (rev 20085)
@@ -616,7 +616,18 @@
 sub _clean_regex_chars {
     my ($search) = @_;
 
-    $search =~ tr/\\.[]()?*+{}^$//d;
+    # Escape metacharacters for SIMILAR TO 
+    # (http://www.postgresql.org/docs/8.4/interactive/functions-matching.html)
+    $search =~ s/\_/\\_/g;
+    $search =~ s/\%/\\%/g;
+    $search =~ s/\|/\\|/g;
+    $search =~ s/\*/\\*/g;
+    $search =~ s/\+/\\+/g;
+    $search =~ s/\[/\\[/g;
+    $search =~ s/\]/\\]/g;
+    $search =~ s/\(/\\(/g;
+    $search =~ s/\)/\\)/g;
+
     return $search;
 }
 



More information about the open-ils-commits mailing list