Made sure DefaultCookie doesn't accept reserved names
This commit is contained in:
parent
566f72abe6
commit
9b0bf68148
@ -25,6 +25,8 @@ import java.util.Collections;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import org.jboss.netty.util.CaseIgnoringComparator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author The Netty Project (netty-dev@lists.jboss.org)
|
* @author The Netty Project (netty-dev@lists.jboss.org)
|
||||||
@ -34,6 +36,21 @@ import java.util.TreeSet;
|
|||||||
*/
|
*/
|
||||||
public class DefaultCookie implements Cookie {
|
public class DefaultCookie implements Cookie {
|
||||||
|
|
||||||
|
private static final Set<String> RESERVED_NAMES = new TreeSet<String>(CaseIgnoringComparator.INSTANCE);
|
||||||
|
|
||||||
|
static {
|
||||||
|
RESERVED_NAMES.add("Domain");
|
||||||
|
RESERVED_NAMES.add("Path");
|
||||||
|
RESERVED_NAMES.add("Comment");
|
||||||
|
RESERVED_NAMES.add("CommentURL");
|
||||||
|
RESERVED_NAMES.add("Discard");
|
||||||
|
RESERVED_NAMES.add("Port");
|
||||||
|
RESERVED_NAMES.add("Max-Age");
|
||||||
|
RESERVED_NAMES.add("Expires");
|
||||||
|
RESERVED_NAMES.add("Version");
|
||||||
|
RESERVED_NAMES.add("Secure");
|
||||||
|
}
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private String value;
|
private String value;
|
||||||
private String domain;
|
private String domain;
|
||||||
@ -74,7 +91,10 @@ public class DefaultCookie implements Cookie {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Refuse known attribute names.
|
if (RESERVED_NAMES.contains(name)) {
|
||||||
|
throw new IllegalArgumentException("reserved name: " + name);
|
||||||
|
}
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
setValue(value);
|
setValue(value);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user