Skip to content

Commit ca9ff83

Browse files
committed
Auto merge of #119327 - notriddle:notriddle/plusencoding, r=GuillaumeGomez
rustdoc: treat query string `+` as space Fixes #119219
2 parents df5d535 + 624885d commit ca9ff83

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/librustdoc/html/static/js/main.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ function preLoadCss(cssUrl) {
279279
const params = {};
280280
window.location.search.substring(1).split("&").
281281
map(s => {
282-
const pair = s.split("=");
282+
// https://github.com/rust-lang/rust/issues/119219
283+
const pair = s.split("=").map(x => x.replace(/\+/g, " "));
283284
params[decodeURIComponent(pair[0])] =
284285
typeof pair[1] === "undefined" ? null : decodeURIComponent(pair[1]);
285286
});

tests/rustdoc-gui/search-form-elements.goml

+9
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,12 @@ call-function: (
137137
"menu_a_color": "#3873ad",
138138
}
139139
)
140+
141+
// Check that search input correctly decodes form encoding.
142+
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=a+b"
143+
wait-for: "#search-tabs" // Waiting for the search.js to load.
144+
assert-property: (".search-input", { "value": "a b" })
145+
// Check that literal + is not treated as space.
146+
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=a%2Bb"
147+
wait-for: "#search-tabs" // Waiting for the search.js to load.
148+
assert-property: (".search-input", { "value": "a+b" })

0 commit comments

Comments
 (0)