Skip to content

Commit cb6db39

Browse files
Add docs for JBoss 7.1.1 incorrectly handling of "[" and "]"
1 parent 214a23e commit cb6db39

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

SERVER_SIDE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,25 @@ var TomcatCookies = Cookies.withConverter({
6464
}
6565
});
6666
```
67+
68+
Alternatively, you can check the [Java Cookie](https://github.com/js-cookie/java-cookie) project, which integrates nicely with js-cookie.
69+
70+
## JBoss 7.1.1
71+
72+
It seems that the servlet implementation of JBoss 7.1.1 [does not read some characters correctly](https://github.com/js-cookie/js-cookie/issues/70#issuecomment-148944674), even though they are allowed as per [RFC 6265](https://tools.ietf.org/html/rfc6265#section-4.1.1). To fix this you need to write a custom converter to send those characters correctly:
73+
74+
```javascript
75+
var JBossCookies = Cookies.withConverter({
76+
write: function (value) {
77+
// Encode all characters according to the "encodeURIComponent" spec
78+
return encodeURIComponent(value)
79+
// Revert the characters that are unnecessarly encoded but are
80+
// allowed in a cookie value
81+
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent)
82+
// Encode again the characters that are not allowed in JBoss 7.1.1, like "[" and "]":
83+
.replace(/[\[\]]/g, encodeURIComponent);
84+
}
85+
});
86+
```
87+
88+
Alternatively, you can check the [Java Cookie](https://github.com/js-cookie/java-cookie) project, which integrates nicely with js-cookie.

0 commit comments

Comments
 (0)