Page MenuHomePhabricator

Quote characters in Special:MediaSearch input field break autocomplete and produce errors
Closed, ResolvedPublicBUG REPORT


This problem was first surfaced in Logstash.

The AutocompleteLookupHandler mixin includes a number of regular expressions and calls to string-processing methods. Something in here is breaking when " characters are entered into the search field.

Steps to Reproduce:

  • Go to Special:MediaSearch and enter a search term that is wrapped in quotes (single or multiple words, does not matter).

Actual Results:

  • The autocomplete results fail to display
  • Warnings and/or errors appear in the JS console, including: Uncaught TypeError: trimmedInput.match(...) is null and jQuery.Deferred exception: result.match(...) is null

Expected Results:

  • Search terms containing quotes should display auto-complete results normally (see below for question about what "normally" means here).

On a related note, I'm noticing search results differ when quotes are present even when the search term is only a single word: "dog" vs dog will produce different results. This happens regardless of whether JS is enabled or not. What is considered "correct" behavior here?

This bug may be related to T277811

Acceptance Criteria

My assumption is that we simply don't want to provide autocomplete suggestions for terms that are wrapped in quotes (or partially wrapped in quotes, for example while the user is in the process of typing the full phrase), with the reasoning that users who are including " characters in their search term have some very specific phrase in mind and don't want auto-suggested alternatives. If this assumption is not correct, then this ticket probably needs to be re-visited.

Things to QA:

  • Users pasting a complete phrase wrapped in quotes ("united states") will not see any auto-complete suggestions, but the pending state in the search input will clear after a moment and searching will work normally without any errors.
  • Users in the process of typing such a phrase ("uni, "united, etc) should see the same behavior as above
  • Users entering non-quoted strings into the search field should see normal (unchanged) behavior with one or more autocomplete results displayed

Event Timeline

egardner updated the task description. (Show Details)
egardner updated the task description. (Show Details)
matthiasmullie added a subscriber: matthiasmullie.

The bug happens when the only input is characters not used for autocomplete (e.g. punctuation)

The related note: that is correct behavior. The " character is a modifier and will change the way the input is interpreted (and will, for now, bypass MediaSearch, which doesn't yet support phrase searches)

Change 673440 had a related patch set uploaded (by Matthias Mullie; owner: Matthias Mullie):
[mediawiki/extensions/WikibaseMediaInfo@master] Handle input parsing regexes with more care

Change 673440 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Handle input parsing regexes with more care

Etonkovidova added subscribers: Matthias, Etonkovidova.

Checked in betalabs - the behavior is as per the acceptance criteria (moved to Verify on Production).

@Matthias - do we need some follow-ups for this task? Below is what I noticed during testing.
(1) Special: Search behaves differently - auto-suggestions are displayed - when it copied ("united states") or being typed. This seems to me more logical behavior.

Screen Shot 2021-03-26 at 6.11.46 PM.png (502×835 px, 96 KB)
Screen Shot 2021-03-26 at 6.17.20 PM.png (508×799 px, 61 KB)

(2) (as it was mentioned ny @egardner) Special:Search just as Special:MediaSearch will display different results for dog and "dog" .

Testing notes: for Verify on Production.
The description of the issue in production wmf.35 (to compare after the fix will be deployed).
(1) Copy the phrase - "united states" (with quotes) - and paste it in the Search box on Special:MediaSearch

  • the error is displayed in the Console Uncaught TypeError: trimmedInput.match(...) is null
  • the running slanted grey lines in the search field never stop

(2) any punctuation mark entered in the text field will produce the Console error.

@Etonkovidova I don't know why you keep pinging me. Must be a confusion.

Etonkovidova closed this task as Resolved.EditedApr 2 2021, 9:16 PM

@Etonkovidova I don't know why you keep pinging me. Must be a confusion.

Sorry, I mixed up the names! :(

Checked in wmf.37 - works as expected.