From dbc97f3b6bcef10f30b96ea48b6464a38c3dc4cf Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Thu, 14 Jul 2022 16:57:24 +0100 Subject: [PATCH] Fix for a stupid oversight in the docstring stuff. I left DOTALL off the replace. :( Here is a fix and a test for the fix. --- src/calibre/utils/search_query_parser.py | 3 ++- src/calibre/utils/search_query_parser_test.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/search_query_parser.py b/src/calibre/utils/search_query_parser.py index bac513a1e4..e0bb483d3b 100644 --- a/src/calibre/utils/search_query_parser.py +++ b/src/calibre/utils/search_query_parser.py @@ -194,7 +194,8 @@ class Parser: # convert docstrings to base64 to avoid all processing. Change the docstring # indicator to something unique with no characters special to the parser. expr = re.sub('(""")(..*?)(""")', - lambda mo: self.docstring_sep + as_hex_unicode(mo.group(2)) + self.docstring_sep, expr) + lambda mo: self.docstring_sep + as_hex_unicode(mo.group(2)) + self.docstring_sep, + expr, flags=re.DOTALL) # Strip out escaped backslashes, quotes and parens so that the # lex scanner doesn't get confused. We put them back later. diff --git a/src/calibre/utils/search_query_parser_test.py b/src/calibre/utils/search_query_parser_test.py index 2097fddc40..9f6a00576c 100644 --- a/src/calibre/utils/search_query_parser_test.py +++ b/src/calibre/utils/search_query_parser_test.py @@ -391,6 +391,7 @@ class TestSQP(unittest.TestCase): t(r'("""a\1b""" AND """c""" OR d)', 'O', '(', 'W', r'a\1b', 'W', 'AND', 'W', 'c', 'W', 'OR', 'W', 'd', 'O', ')') t(r'template:="""a\1b"""', 'W', r'template:=a\1b') + t('template:="""a\nb"""', 'W', 'template:=a\nb') t(r'template:"""=a\1b"""', 'W', r'template:=a\1b') t(r'template:"""program: return ("\"1\"")#@#n:1"""', 'W', r'template:program: return ("\"1\"")#@#n:1')