Page MenuHomePhabricator

Portal: search suggestions are not continually updated when a parenthesis is in search query
Closed, ResolvedPublic1 Estimated Story Points

Description

I can see an error in the JS console when I type a parenthesis, the error seems to be related to a regex not being escaped correctly.
Typing wild tales ( will trigger the following error in the console.

Uncaught SyntaxError: Invalid regular expression: /wild%20tales%20(/: Unterminated groupi @ index-3ca8c4cd85.js:1o @ index-3ca8c4cd85.js:1window.portalOpensearchCallback @ index-3ca8c4cd85.js:1(anonymous function) @ api.php?action=query&format=json&generator=prefixsearch&prop=pageprops|pageimages|pageterms&redirec…:1
index-3ca8c4cd85.js:1 Uncaught SyntaxError: Invalid regular expression: /wild%20tales%20(a/: Unterminated groupi @ index-3ca8c4cd85.js:1o @ index-3ca8c4cd85.js:1window.portalOpensearchCallback @ index-3ca8c4cd85.js:1(anonymous function) @ api.php?action=query&format=json&generator=prefixsearch&prop=pageprops|pageimages|pageterms&redirec…:1

To reproduce:
Go to wikipedia.org and type:

how I met your mother (seas

and you'll notice that the suggestions stop updating. You can also try this by typing in

wild tales (fil

View a screen shot: https://imgur.com/a/cLsWb of the issue (thanks @Deskana!)

Event Timeline

debt renamed this task from Portal: search suggestions are not updated when I type a parenthesis. to Portal: search suggestions are not continually updated when a parenthesis is in search query.Mar 17 2016, 9:35 PM
debt triaged this task as High priority.
debt updated the task description. (Show Details)
debt added a project: Discovery-Portal-Sprint.
debt moved this task from Backlog to What's Next on the Discovery-Portal-Sprint board.
debt added a subscriber: Deskana.
debt added a subscriber: Jdrewniak.
Jdrewniak moved this task from What's Next to In Progress on the Discovery-Portal-Sprint board.
Jdrewniak set the point value for this task to 1.

Change 278968 had a related patch set uploaded (by Jdrewniak):
Escapes search strings for use in regexp. Also fixes T130657, by filtering results array to remove undefined values.

https://gerrit.wikimedia.org/r/278968

Change 278968 merged by jenkins-bot:
Escapes search strings for use in regexp. Also fixes T130657 by skipping undefined values when generating typeahead template.

https://gerrit.wikimedia.org/r/278968

debt subscribed.

Closing and this will be part of this production update: https://phabricator.wikimedia.org/T130755