-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revisit encoding/decoding implementation
Our RFC 6265 based cookie name + value encoding was based on the requirements for server implementers, and as such too strict. We need to look at RFC 6265 section 5.2, requirements for user agents. But even the algorithm described in section 5.2 isn't that relevant for us, in that we had to follow the steps when writing a cookie with this library. This is left to the browser vendors who have to implement the setter functionality behind `document.cookie`. All we have to do is avoid surprises when said algorithm is being followed while `document.cookie = ...` is being executed with the cookie string we're constructing. It means we have to encode ";" and "=" in the cookie name, and ";" in the cookie value. Follow-up to discussion in #595.
- Loading branch information
Showing
7 changed files
with
50 additions
and
1,416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
export default { | ||
read: function (value) { | ||
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent) | ||
return value.replace(/%3B/g, ';') | ||
}, | ||
write: function (value) { | ||
return encodeURIComponent(value).replace( | ||
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, | ||
decodeURIComponent | ||
) | ||
return value.replace(/;/g, '%3B') | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.