diff options
| author | bors <bors@rust-lang.org> | 2023-12-27 11:47:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-27 11:47:24 +0000 |
| commit | ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e (patch) | |
| tree | 991e0b171e4efbe0277daf13486acd19c9972891 | |
| parent | df5d53585a0c53eee7889602202693c2597c2a6c (diff) | |
| parent | 624885d242fb8ecefa5993e834f429a635b86178 (diff) | |
| download | rust-ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e.tar.gz rust-ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e.zip | |
Auto merge of #119327 - notriddle:notriddle/plusencoding, r=GuillaumeGomez
rustdoc: treat query string `+` as space Fixes #119219
| -rw-r--r-- | src/librustdoc/html/static/js/main.js | 3 | ||||
| -rw-r--r-- | tests/rustdoc-gui/search-form-elements.goml | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 63ab56053af..e205ba46dbf 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -279,7 +279,8 @@ function preLoadCss(cssUrl) { const params = {}; window.location.search.substring(1).split("&"). map(s => { - const pair = s.split("="); + // https://github.com/rust-lang/rust/issues/119219 + const pair = s.split("=").map(x => x.replace(/\+/g, " ")); params[decodeURIComponent(pair[0])] = typeof pair[1] === "undefined" ? null : decodeURIComponent(pair[1]); }); diff --git a/tests/rustdoc-gui/search-form-elements.goml b/tests/rustdoc-gui/search-form-elements.goml index a4e22364859..0ea61a4f0eb 100644 --- a/tests/rustdoc-gui/search-form-elements.goml +++ b/tests/rustdoc-gui/search-form-elements.goml @@ -137,3 +137,12 @@ call-function: ( "menu_a_color": "#3873ad", } ) + +// Check that search input correctly decodes form encoding. +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=a+b" +wait-for: "#search-tabs" // Waiting for the search.js to load. +assert-property: (".search-input", { "value": "a b" }) +// Check that literal + is not treated as space. +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=a%2Bb" +wait-for: "#search-tabs" // Waiting for the search.js to load. +assert-property: (".search-input", { "value": "a+b" }) |
