File tree 1 file changed +9
-1
lines changed
src/librustdoc/html/static/js
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,14 @@ const getVar = (function getVar(name) {
101
101
} ) ;
102
102
103
103
function switchTheme ( newThemeName , saveTheme ) {
104
+ const themeNames = getVar ( "themes" ) . split ( "," ) . filter ( t => t ) ;
105
+ themeNames . push ( ...builtinThemes ) ;
106
+
107
+ // Ensure that the new theme name is among the defined themes
108
+ if ( themeNames . indexOf ( newThemeName ) === - 1 ) {
109
+ return ;
110
+ }
111
+
104
112
// If this new value comes from a system setting or from the previously
105
113
// saved theme, no need to save it.
106
114
if ( saveTheme ) {
@@ -115,7 +123,7 @@ function switchTheme(newThemeName, saveTheme) {
115
123
window . currentTheme = null ;
116
124
}
117
125
} else {
118
- const newHref = getVar ( "root-path" ) + newThemeName +
126
+ const newHref = getVar ( "root-path" ) + encodeURIComponent ( newThemeName ) +
119
127
getVar ( "resource-suffix" ) + ".css" ;
120
128
if ( ! window . currentTheme ) {
121
129
// If we're in the middle of loading, document.write blocks
You can’t perform that action at this time.
0 commit comments