Skip to content

Commit

Permalink
Auto merge of #119327 - notriddle:notriddle/plusencoding, r=Guillaume…
Browse files Browse the repository at this point in the history
…Gomez

rustdoc: treat query string `+` as space

Fixes #119219
  • Loading branch information
bors committed Dec 27, 2023
2 parents df5d535 + 624885d commit ca9ff83
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
});
Expand Down
9 changes: 9 additions & 0 deletions tests/rustdoc-gui/search-form-elements.goml
Original file line number Diff line number Diff line change
Expand Up @@ -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" })

0 comments on commit ca9ff83

Please sign in to comment.