File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
src/librustdoc/html/static/js Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff 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
3830const localStoredTheme = getSettingValue ( "theme" ) ;
@@ -109,10 +101,11 @@ const getVar = (function getVar(name) {
109101} ) ;
110102
111103function 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
You can’t perform that action at this time.
0 commit comments