File tree 1 file changed +5
-12
lines changed
src/librustdoc/html/static/js
1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -24,15 +24,7 @@ function getSettingValue(settingName) {
24
24
return def ;
25
25
}
26
26
}
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 ;
36
28
}
37
29
38
30
const localStoredTheme = getSettingValue ( "theme" ) ;
@@ -109,10 +101,11 @@ const getVar = (function getVar(name) {
109
101
} ) ;
110
102
111
103
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 ) ;
114
106
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 ) {
116
109
return ;
117
110
}
118
111
You can’t perform that action at this time.
0 commit comments