Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unchecked exception handling #9637

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions core/src/main/java/hudson/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,23 @@ public static String getCookie(HttpServletRequest req, String name, String defau
}

private static final Pattern ICON_SIZE = Pattern.compile("\\d+x\\d+");


/**
* Validates the given icon size.
*
* @param iconSize the size of the icon to validate; must not be null
* @return the validated icon size if valid
* @throws SecurityException if the icon size is invalid
*/
@Restricted(NoExternalUse.class)
public static String validateIconSize(@NonNull String iconSize) throws SecurityException {
if (!ICON_SIZE.matcher(iconSize).matches()) {
throw new SecurityException("Invalid iconSize: " + iconSize);
}
return iconSize;
}

@Restricted(NoExternalUse.class)
public static String validateIconSize(String iconSize) throws SecurityException {
if (!ICON_SIZE.matcher(iconSize).matches()) {
throw new SecurityException("invalid iconSize");
}
return iconSize;
}

/**
* Gets the suffix to use for YUI JavaScript.
Expand Down