Repository navigation
fix(core): OpenSearch searches from the address bar, Chrome's size limit, suggestions and caching - #5386
Merged
Conversation
Browsers drop suggestions whose first element differs from the text typed, so a trailing space dropped them. A query that isn't text suggests nothing rather than searching for "Array".
…s query Every word added two LIKE conditions, so a guest could build a query SQLite refuses with a 500, and load any database.
Words were only completed at the start of a title or after a space, so "solv" didn't find "[Solved] …" and "fibre" didn't find "carbon-fibre".
… on SQLite SQLite's LIKE folds the case of ASCII letters only, so "über" didn't find "Über…".
XML can't contain them, so a title pasted with one made the document ill-formed and browsers refused it.
XMLWriter is a separate PHP extension that core doesn't require, and some distributions package it on its own. DOM is already an install requirement.
An uploaded .ico is embedded as it is, and a 60KB one made the document 81KB. Chrome ignores a description over 50,000 bytes, so it never added the forum. Images that don't fit are left out.
…ts size It was always declared 16x16, whatever sizes it held.
…hange The search address depended on the homepage, but browsers keep the one they were given: after the homepage changed, searches landed on a page that ignored them. /opensearch/search sends them on to the discussion list wherever it is now, with spaces encoded as %20 rather than the "+" browsers send, which the frontend kept.
The forum adds the visitor's session cookie and CSRF token to it, which a cache honouring "public" could hand to other visitors.
…rect Like the OpenSearch description, they carry the visitor's session cookie and CSRF token, which a cache honouring "public" could hand to others.
…request The favicon was read from the assets disk, decoded, resized and encoded as an .ico each time. It is kept for a day by where it is stored, which changes when it is replaced.
… address A browser's address bar sends ?q=hello+world, and Mithril kept the "+": the search box showed it, and sorting or loading more searched for it. Mithril also turns "true" and "false" into booleans, so a search for "true" broke the discussion list and one for "false" was ignored.
The homepage is served at the root and the frontend has nothing at its own address, so the router fell back to the root without the query: a search a browser saved as /all?q=… lost it once /all became the homepage.
MySQL, MariaDB and PostgreSQL find "Café" for "cafe", but the check for where words start compared accents, and dropped it.
…others
Only the 100 most recently active titles containing the words were checked
for words starting there, so on a busy forum newer titles with the word
inside another ("art" in "smart") hid older ones that start with it.
…h a trailing slash The router strips the slash only after the address is checked, so /all/?q=… still lost its query.
The cache held the favicon's raw bytes, however big, before images too big for Chrome were left out. It now holds only the images that fit, as text, which every cache store can keep.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: no issue filed. Follow-up to #5321 and #5328.
Changes proposed in this pull request:
A review of OpenSearch, and driving it in headless Chromium against a dev forum, turned up searches from the address bar that went wrong, a forum Chrome never added, and suggestions that missed obvious titles.
Searches from the address bar:
true/false. Browsers send a space as+(Chromium escapes{searchTerms}withEscapeQueryParamValue(…, true)), and Mithril's query parser keeps the+.?q=hello+worldshowedhello+worldin the search box, and sorting or loading more searched for it; only the first page, rendered by the server, was right. Mithril also turnstrueandfalseinto booleans: a search fortruethrew insearchToQueryand left the discussion list empty, and one forfalsewas ignored.GlobalSearchStatenow readsqfrom the address withURLSearchParams./opensearch/search?q=, which redirects to the discussion list wherever it is, with spaces as%20./allas the homepage,/all?q=…(an engine saved while another page was the homepage) fell back to/without the query. The frontend now moves the address to the root and keeps the query, with or without a trailing slash.The description:
max_body_sizeinTemplateURLFetcher). An uploaded.icowas embedded as it was: a 60KB one made the document 81KB, and Chrome added nothing. Images that don't fit are left out, and Chrome then shows/favicon.ico. An.icoalso declares its own size rather than 16×16.data:URIs, by where the favicon is stored, which changes when it is replaced.Caching:
/opensearchwaspublic, max-age=3600, and the forum adds the visitor's session cookie and CSRF token to it. A shared cache that honouredpubliccould hand one visitor's session to others. It isprivatenow, and so are/manifestand the/favicon.icoredirect, which had the same problem before OpenSearch.Suggestions:
qthat isn't text suggests nothing.LIKEconditions, so a guest could build a query SQLite refuses with a 500.LIKEfolds ASCII only, accented words match in any case ("über" finds "Über…").Reviewers should focus on:
/, and sinceTemplateURLData::ActiveStatusit adds it as inactive (is_active=0). Inactive engines can't be used for keyword search (CanBeUsedForKeywordMatching) until someone activates them under "Inactive shortcuts" inchrome://settings/searchEngines. Headless Chromium 156 stored the forum with the right search and suggestion addresses andis_active=0. Forums in a subfolder are never added automatically.ILIKE; the PHP check now agrees with them.OpenSearchDescriptiontakes a cache repository in its constructor, andsearchPage()is public.Necessity
Confirmed
.ico.)yarn testinjs/).composer test).