Blame SOURCES/BZ-1096147-history-search-crash.patch

65829f
commit 5efc1e1b88398da7f89dcb9055d62481bb288a8a
65829f
Author: James Antill <james@and.org>
65829f
Date:   Tue Sep 16 16:33:33 2014 -0400
65829f
65829f
    Workaround history searching for [abc] character lists failures. BZ 1096147.
65829f
65829f
diff --git a/yum/history.py b/yum/history.py
65829f
index 2f423d9..fd80191 100644
65829f
--- a/yum/history.py
65829f
+++ b/yum/history.py
65829f
@@ -20,6 +20,7 @@
65829f
 import time
65829f
 import os, os.path
65829f
 import glob
65829f
+import re
65829f
 from weakref import proxy as weakref
65829f
 
65829f
 from sqlutils import sqlite, executeSQL, sql_esc_glob
65829f
@@ -1422,6 +1423,17 @@ class YumHistory:
65829f
         if cur is None:
65829f
             return set()
65829f
 
65829f
+        #  This is kind of a hack, we can't do 'y[u]m' in SQL. In real yum
65829f
+        # we manually load everything and then do it inside yum (which is slow
65829f
+        # and a lot of code, but nobody uses it anyway and we already had the
65829f
+        # code). Here we don't have the code though, and still nobody will use
65829f
+        # it. So we cheat:
65829f
+        #  1. Convert 'y[u]m' into 'y?m' ... it returns more answers than it
65829f
+        #     should, but the correct answers are there.
65829f
+        #  2. Convert 'y[m' info 'y!m' ... neither will match anything, so w/e.
65829f
+        patterns = [re.sub('\[[^]]+\]', '?', x).replace('[', '!')
65829f
+                    for x in patterns]
65829f
+
65829f
         data = _setupHistorySearchSQL(patterns, ignore_case)
65829f
         (need_full, npatterns, fields, names) = data
65829f