Skip to content

Commit e4c0401

Browse files
author
Chad Norvell
committed
rustdoc: Remove regex sanitation
1 parent d8287d0 commit e4c0401

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/librustdoc/html/static/js/storage.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,7 @@ function getSettingValue(settingName) {
2424
return def;
2525
}
2626
}
27-
// Strip out characters we don't expect to find in settings values.
28-
// This prevents an injection vulnerability where someone could plant
29-
// JS code into the localStorage value, which could be executed when
30-
// we pull it out.
31-
if (current) {
32-
return current.replace(/[\s()[\]{}*"'`<>.:;=&|]/g,"");
33-
}
34-
35-
return null;
27+
return current;
3628
}
3729

3830
const localStoredTheme = getSettingValue("theme");
@@ -109,10 +101,11 @@ const getVar = (function getVar(name) {
109101
});
110102

111103
function switchTheme(newThemeName, saveTheme) {
112-
const theme_names = getVar("themes").split(",").filter(t => t);
113-
theme_names.push("light", "dark", "ayu");
104+
const themeNames = getVar("themes").split(",").filter(t => t);
105+
themeNames.push(...builtinThemes);
114106

115-
if (theme_names.indexOf(newThemeName) == -1) {
107+
// Ensure that the new theme name is among the defined themes
108+
if (themeNames.indexOf(newThemeName) === -1) {
116109
return;
117110
}
118111

0 commit comments

Comments
 (0)