Consider comma separated lists of IP addresses in addIPAddress()

This commit is contained in:
hns 2003-10-09 18:32:26 +00:00
parent aa1e10691f
commit 8774a52e44

View file

@ -469,14 +469,20 @@ public abstract class AbstractServletClient extends HttpServlet {
} }
/** /**
* Adds an the 3 most significant bytes of an IP address to the * Adds an the 3 most significant bytes of an IP address header to the
* session cookie id. * session cookie id. Some headers may contain a list of IP addresses
* separated by comma - in that case, care is taken that only the first
* one is considered.
*/ */
private void addIPAddress(StringBuffer b, String addr) { private void addIPAddress(StringBuffer b, String addr) {
if (addr != null) { if (addr != null) {
int cut = addr.lastIndexOf("."); int cut = addr.indexOf(',');
if (cut > -1) {
addr = addr.substring(0, cut);
}
cut = addr.lastIndexOf('.');
if (cut == -1) { if (cut == -1) {
cut = addr.lastIndexOf(":"); cut = addr.lastIndexOf(':');
} }
if (cut > -1) { if (cut > -1) {
b.append(addr.substring(0, cut+1)); b.append(addr.substring(0, cut+1));