File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/librustdoc/html/static/js Expand file tree Collapse file tree 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) {
101101} ) ;
102102
103103function 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+
104112 // If this new value comes from a system setting or from the previously
105113 // saved theme, no need to save it.
106114 if ( saveTheme ) {
@@ -115,7 +123,7 @@ function switchTheme(newThemeName, saveTheme) {
115123 window . currentTheme = null ;
116124 }
117125 } else {
118- const newHref = getVar ( "root-path" ) + newThemeName +
126+ const newHref = getVar ( "root-path" ) + encodeURIComponent ( newThemeName ) +
119127 getVar ( "resource-suffix" ) + ".css" ;
120128 if ( ! window . currentTheme ) {
121129 // If we're in the middle of loading, document.write blocks
You can’t perform that action at this time.
0 commit comments