diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 510d4b9b0ec4..668444b14bd5 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -125,6 +125,7 @@ import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.text.DecimalFormat; +import java.text.MessageFormat; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -2582,4 +2583,25 @@ public static String generateItemId() { public static ExtensionList getSearchFactories() { return SearchFactory.all(); } + + /** + * @param keyboardShortcut the shortcut to be translated + * @return the translated shortcut, e.g. CMD+K to ⌘+K for macOS, CTRL+K for Windows + */ + @Restricted(NoExternalUse.class) + public static String translateModifierKeysForUsersPlatform(String keyboardShortcut) { + StaplerRequest2 currentRequest = Stapler.getCurrentRequest2(); + currentRequest.getWebApp().getDispatchValidator().allowDispatch(currentRequest, Stapler.getCurrentResponse2()); + String userAgent = currentRequest.getHeader("User-Agent"); + + List platformsThatUseCommand = List.of("MAC", "IPHONE", "IPAD"); + boolean useCmdKey = platformsThatUseCommand.stream().anyMatch(e -> userAgent.toUpperCase().contains(e)); + + return keyboardShortcut.replace("CMD", useCmdKey ? "⌘" : "CTRL"); + } + + @Restricted(NoExternalUse.class) + public static String formatMessage(String format, Object args) { + return MessageFormat.format(format, args); + } } diff --git a/core/src/main/java/hudson/model/Descriptor.java b/core/src/main/java/hudson/model/Descriptor.java index 33c981d657f5..c55b7982695e 100644 --- a/core/src/main/java/hudson/model/Descriptor.java +++ b/core/src/main/java/hudson/model/Descriptor.java @@ -474,6 +474,12 @@ public void calcAutoCompleteSettings(String field, Map attribute if (method == null) return; // no auto-completion + // build query parameter line by figuring out what should be submitted + List depends = buildFillDependencies(method, new ArrayList<>()); + if (!depends.isEmpty()) { + attributes.put("fillDependsOn", String.join(" ", depends)); + } + attributes.put("autoCompleteUrl", String.format("%s/%s/autoComplete%s", getCurrentDescriptorByNameUrl(), getDescriptorUrl(), capitalizedFieldName)); } diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index 0e3cc894148a..22764fd403d0 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -217,7 +217,7 @@ public long getDataTimestamp() { return updateData(DownloadService.loadJSON(new URL(getUrl() + "?id=" + URLEncoder.encode(getId(), StandardCharsets.UTF_8) + "&version=" + URLEncoder.encode(Jenkins.VERSION, StandardCharsets.UTF_8))), signatureCheck); } - private FormValidation updateData(String json, boolean signatureCheck) + protected FormValidation updateData(String json, boolean signatureCheck) throws IOException { dataTimestamp = System.currentTimeMillis(); diff --git a/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java b/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java index 1a6ebe66f749..f55576dec4d6 100644 --- a/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java +++ b/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java @@ -839,6 +839,10 @@ public Details newInstance(StaplerRequest2 req, JSONObject formData) throws Form throw new FormException("Please confirm the password by typing it twice", "user.password2"); } + if (FIPS140.useCompliantAlgorithms() && pwd.length() < FIPS_PASSWORD_LENGTH) { + throw new FormException(Messages.HudsonPrivateSecurityRealm_CreateAccount_FIPS_PasswordLengthInvalid(), "user.password"); + } + // will be null if it wasn't encrypted String data = Protector.unprotect(pwd); String data2 = Protector.unprotect(pwd2); diff --git a/core/src/main/resources/lib/layout/header/searchbox.jelly b/core/src/main/resources/lib/layout/header/searchbox.jelly index e1112bbb90c4..033dc2ab0407 100644 --- a/core/src/main/resources/lib/layout/header/searchbox.jelly +++ b/core/src/main/resources/lib/layout/header/searchbox.jelly @@ -5,7 +5,18 @@ -