Skip to content

Commit ff53e4a

Browse files
author
Eva Müller
committed
fix: Do not modify keyboard shortcut when User-Agent header is not set
1 parent 4e52807 commit ff53e4a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

core/src/main/java/hudson/Functions.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,11 +2633,13 @@ public static String translateModifierKeysForUsersPlatform(String keyboardShortc
26332633
StaplerRequest2 currentRequest = Stapler.getCurrentRequest2();
26342634
currentRequest.getWebApp().getDispatchValidator().allowDispatch(currentRequest, Stapler.getCurrentResponse2());
26352635
String userAgent = currentRequest.getHeader("User-Agent");
2636-
2637-
List<String> platformsThatUseCommand = List.of("MAC", "IPHONE", "IPAD");
2638-
boolean useCmdKey = platformsThatUseCommand.stream().anyMatch(e -> userAgent.toUpperCase().contains(e));
2639-
2640-
return keyboardShortcut.replace("CMD", useCmdKey ? "⌘" : "CTRL");
2636+
if(userAgent != null) {
2637+
List<String> platformsThatUseCommand = List.of("MAC", "IPHONE", "IPAD");
2638+
boolean useCmdKey = platformsThatUseCommand.stream().anyMatch(e -> userAgent.toUpperCase().contains(e));
2639+
return keyboardShortcut.replace("CMD", useCmdKey ? "⌘" : "CTRL");
2640+
} else {
2641+
return keyboardShortcut;
2642+
}
26412643
}
26422644

26432645
@Restricted(NoExternalUse.class)

0 commit comments

Comments
 (0)