From 509e0149968a8d566bf728ea23c259fbbb4e5da5 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Wed, 2 Mar 2011 20:05:36 +0000 Subject: [PATCH] Escape leading periods with a second periond on non-hierarchical item searches. --- src/calibre/gui2/tag_view.py | 6 ++++-- src/calibre/library/caches.py | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py index b310ce55fb..6371f541a7 100644 --- a/src/calibre/gui2/tag_view.py +++ b/src/calibre/gui2/tag_view.py @@ -1591,9 +1591,11 @@ class TagsModel(QAbstractItemModel): # {{{ if tag in nodes_seen: continue nodes_seen.add(tag) + n = name.replace(r'"', r'\"') + if name.startswith('.'): + n = '.' + n ans.append('%s%s:"=%s%s"'%(prefix, category, - '.' if use_prefix else '', - name.replace(r'"', r'\"'))) + '.' if use_prefix else '', n)) return ans def find_item_node(self, key, txt, start_path, equals_match=False): diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py index 4c9fde3d9a..4f2d80192a 100644 --- a/src/calibre/library/caches.py +++ b/src/calibre/library/caches.py @@ -121,11 +121,17 @@ CONTAINS_MATCH = 0 EQUALS_MATCH = 1 REGEXP_MATCH = 2 def _match(query, value, matchkind): + if query.startswith('..'): + print 'here', query + query = query[1:] + prefix_match_ok = False + else: + prefix_match_ok = True for t in value: t = icu_lower(t) try: ### ignore regexp exceptions, required because search-ahead tries before typing is finished if (matchkind == EQUALS_MATCH): - if query[0] == '.': + if prefix_match_ok and query[0] == '.': if t.startswith(query[1:]): ql = len(query) - 1 if (len(t) == ql) or (t[ql:ql+1] == '.'):