GUACAMOLE-784: Merge changes which tolerate the presence of a port number within X-Forwarded-For headers.

This commit is contained in:
Mike Jumper
2020-01-25 22:34:05 -08:00
committed by GitHub

View File

@@ -106,11 +106,16 @@ public class AuthenticationService {
*/ */
private static final String IP_ADDRESS_REGEX = "(" + IPV4_ADDRESS_REGEX + "|" + IPV6_ADDRESS_REGEX + ")"; private static final String IP_ADDRESS_REGEX = "(" + IPV4_ADDRESS_REGEX + "|" + IPV6_ADDRESS_REGEX + ")";
/**
* Regular expression which matches any Port Number.
*/
private static final String PORT_NUMBER_REGEX = "(:[0-9]{1,5})?";
/** /**
* Pattern which matches valid values of the de-facto standard * Pattern which matches valid values of the de-facto standard
* "X-Forwarded-For" header. * "X-Forwarded-For" header.
*/ */
private static final Pattern X_FORWARDED_FOR = Pattern.compile("^" + IP_ADDRESS_REGEX + "(, " + IP_ADDRESS_REGEX + ")*$"); private static final Pattern X_FORWARDED_FOR = Pattern.compile("^" + IP_ADDRESS_REGEX + PORT_NUMBER_REGEX + "(, " + IP_ADDRESS_REGEX + PORT_NUMBER_REGEX + ")*$");
/** /**
* Returns a formatted string containing an IP address, or list of IP * Returns a formatted string containing an IP address, or list of IP