Do not modify keyboard shortcut when User-Agent header is not set (#10413)

* fix: Do not modify keyboard shortcut when User-Agent header is not set

* Add whitespace after if to pass code style check
This commit is contained in:
Eva Müller 2025-03-21 08:05:53 +01:00 committed by GitHub
parent a9efc2c277
commit 73185b257d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 5 deletions

View File

@ -2633,11 +2633,13 @@ public class Functions {
StaplerRequest2 currentRequest = Stapler.getCurrentRequest2();
currentRequest.getWebApp().getDispatchValidator().allowDispatch(currentRequest, Stapler.getCurrentResponse2());
String userAgent = currentRequest.getHeader("User-Agent");
if (userAgent != null) {
List<String> platformsThatUseCommand = List.of("MAC", "IPHONE", "IPAD");
boolean useCmdKey = platformsThatUseCommand.stream().anyMatch(e -> userAgent.toUpperCase().contains(e));
return keyboardShortcut.replace("CMD", useCmdKey ? "" : "CTRL");
} else {
return keyboardShortcut;
}
}
@Restricted(NoExternalUse.class)