File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
1
package org .json ;
2
2
3
+ import java .util .Locale ;
4
+
3
5
/*
4
6
Copyright (c) 2002 JSON.org
5
7
@@ -74,7 +76,9 @@ public static String escape(String string) {
74
76
* The name will be stored under the key "name", and the value will be
75
77
* stored under the key "value". This method does not do checking or
76
78
* validation of the parameters. It only converts the cookie string into
77
- * a JSONObject.
79
+ * a JSONObject. All attribute names are converted to lower case keys in the
80
+ * JSONObject (HttpOnly => httponly). If an attribute is specified more than
81
+ * once, only the value found closer to the end of the cookie-string is kept.
78
82
* @param string The cookie specification string.
79
83
* @return A JSONObject containing "name", "value", and possibly other
80
84
* members.
@@ -104,7 +108,7 @@ public static JSONObject toJSONObject(String string) {
104
108
x .next ();
105
109
// parse the remaining cookie attributes
106
110
while (x .more ()) {
107
- name = unescape (x .nextTo ("=;" )).trim ();
111
+ name = unescape (x .nextTo ("=;" )).trim (). toLowerCase ( Locale . ROOT ) ;
108
112
// don't allow a cookies attributes to overwrite it's name or value.
109
113
if ("name" .equalsIgnoreCase (name )) {
110
114
throw new JSONException ("Illegal attribute name: 'name'" );
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ public void booleanAttribute() {
84
84
JSONObject jo = Cookie .toJSONObject (cookieStr );
85
85
assertTrue ("has key 'name'" , jo .has ("name" ));
86
86
assertTrue ("has key 'value'" , jo .has ("value" ));
87
- assertTrue ("has key 'myAttribute'" , jo .has ("myAttribute " ));
87
+ assertTrue ("has key 'myAttribute'" , jo .has ("myattribute " ));
88
88
}
89
89
90
90
/**
@@ -177,7 +177,7 @@ public void convertCookieToString() {
177
177
"thisWont=beIncluded;" +
178
178
"secure" ;
179
179
String expectedCookieStr =
180
- "{\" thisWont \" :\" beIncluded\" ," +
180
+ "{\" thiswont \" :\" beIncluded\" ," +
181
181
"\" path\" :\" /\" ," +
182
182
"\" expires\" :\" Wed, 19-Mar-2014 17:53:53 GMT\" ," +
183
183
"\" ___domain\" :\" .yahoo.com\" ," +
You can’t perform that action at this time.
0 commit comments