Revert code to handle smart quotes as quote delimiters in the search query parser

It is still possible to type normal quotes in safari by long tapping the
quote button
This commit is contained in:
Kovid Goyal
2018-01-18 17:27:07 +05:30
parent 2de4dc5a73
commit f258b3d53e
2 changed files with 3 additions and 6 deletions
+3 -4
View File
@@ -142,15 +142,14 @@ class Parser(object):
WORD = 2
QUOTED_WORD = 3
EOF = 4
REPLACEMENTS = tuple((u'\\' + x, unichr(i + 1)) for i, x in enumerate(ur'\"()“”'))
REPLACEMENTS = tuple((u'\\' + x, unichr(i + 1)) for i, x in enumerate(ur'\"()'))
# Had to translate named constants to numeric values
lex_scanner = re.Scanner([
(ur'[()]', lambda x,t: (Parser.OPCODE, t)),
(ur'@.+?:[^")\s]+', lambda x,t: (Parser.WORD, unicode(t))),
(ur'[^"()\s]+', lambda x,t: (Parser.WORD, unicode(t))),
(ur'@.+?:[^")\s]+', lambda x,t: (Parser.WORD, unicode(t))),
(ur'[^"()\s]+', lambda x,t: (Parser.WORD, unicode(t))),
(ur'".*?((?<!\\)")', lambda x,t: (Parser.QUOTED_WORD, t[1:-1])),
(ur'“.*?((?<!\\)”)', lambda x,t: (Parser.QUOTED_WORD, t[1:-1])),
(ur'\s+', None)
], flags=re.DOTALL)
@@ -385,10 +385,8 @@ class TestSQP(unittest.TestCase):
t('xxx', 'W', 'xxx')
t('"a \\" () b"', 'Q', 'a " () b')
t('“a \\"\\” () b”', 'Q', 'a "“” () b')
t('"a“b"', 'Q', 'a“b')
t('"a”b"', 'Q', 'a”b')
t('a:“b ”', 'W', 'a:', 'Q', 'b ')
def find_tests():