Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb8764d2

Browse files
committed
Fix allowed cookie values chars, backportAsyncHttpClient#1115
1 parente8ac297 commitb8764d2

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

‎src/main/java/com/ning/http/client/cookie/CookieUtil.java‎

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,46 @@ public class CookieUtil {
2222

2323
privatestaticfinalBitSetVALID_COOKIE_NAME_OCTETS =validCookieNameOctets(VALID_COOKIE_VALUE_OCTETS);
2424

25+
// cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
2526
// US-ASCII characters excluding CTLs, whitespace, DQUOTE, comma, semicolon, and backslash
2627
privatestaticBitSetvalidCookieValueOctets() {
27-
2828
BitSetbits =newBitSet(8);
29-
for (inti =35;i <127;i++) {
30-
// US-ASCII characters excluding CTLs (%x00-1F / %x7F)
29+
bits.set(0x21);
30+
for (inti =0x23;i <=0x2B;i++) {
31+
bits.set(i);
32+
}
33+
for (inti =0x2D;i <=0x3A;i++) {
34+
bits.set(i);
35+
}
36+
for (inti =0x3C;i <=0x5B;i++) {
37+
bits.set(i);
38+
}
39+
for (inti =0x5D;i <=0x7E;i++) {
3140
bits.set(i);
3241
}
33-
bits.set('"',false);// exclude DQUOTE = %x22
34-
bits.set(',',false);// exclude comma = %x2C
35-
bits.set(';',false);// exclude semicolon = %x3B
36-
bits.set('\\',false);// exclude backslash = %x5C
3742
returnbits;
3843
}
3944

40-
//token = 1*<any CHAR except CTLs or separators>
41-
//separators = "(" | ")" | "<" | ">" | "@"
42-
//| "," | ";" | ":" | "\" | <">
43-
//| "/" | "[" | "]" | "?" | "="
44-
//| "{" | "}" | SP | HT
45+
// token = 1*<any CHAR except CTLs or separators>
46+
// separators = "(" | ")" | "<" | ">" | "@"
47+
// | "," | ";" | ":" | "\" | <">
48+
// | "/" | "[" | "]" | "?" | "="
49+
// | "{" | "}" | SP | HT
4550
privatestaticBitSetvalidCookieNameOctets(BitSetvalidCookieValueOctets) {
4651
BitSetbits =newBitSet(8);
47-
bits.or(validCookieValueOctets);
52+
for (inti =32;i <127;i++) {
53+
bits.set(i);
54+
}
4855
bits.set('(',false);
4956
bits.set(')',false);
5057
bits.set('<',false);
5158
bits.set('>',false);
5259
bits.set('@',false);
60+
bits.set(',',false);
61+
bits.set(';',false);
5362
bits.set(':',false);
63+
bits.set('\\',false);
64+
bits.set('"',false);
5465
bits.set('/',false);
5566
bits.set('[',false);
5667
bits.set(']',false);
@@ -62,7 +73,7 @@ private static BitSet validCookieNameOctets(BitSet validCookieValueOctets) {
6273
bits.set('\t',false);
6374
returnbits;
6475
}
65-
76+
6677
staticintfirstInvalidCookieNameOctet(CharSequencecs) {
6778
returnfirstInvalidOctet(cs,VALID_COOKIE_NAME_OCTETS);
6879
}
@@ -103,10 +114,10 @@ static long computeExpiresAsMaxAge(String expires) {
103114
returnmaxAgeMillis /1000 + (maxAgeMillis %1000 !=0 ?1 :0);
104115
}
105116
}
106-
117+
107118
returnLong.MIN_VALUE;
108119
}
109-
120+
110121
privateCookieUtil() {
111122
// Unused
112123
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp