Skip to content

Commit 4f63e4c

Browse files
author
Chad Norvell
committed
rustdoc: Handle null localStorage value
1 parent a26c3de commit 4f63e4c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ function getSettingValue(settingName) {
2828
// This prevents an injection vulnerability where someone could plant
2929
// JS code into the localStorage value, which could be executed when
3030
// we pull it out.
31-
return current.replace(/[\s()[\]{}*"'`<>.:;=&|]/g,"");
31+
if (current) {
32+
return current.replace(/[\s()[\]{}*"'`<>.:;=&|]/g,"");
33+
}
34+
35+
return null;
3236
}
3337

3438
const localStoredTheme = getSettingValue("theme");

0 commit comments

Comments
 (0)