Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace 'node-crc' with MIT licensed 'buffer-crc32' #714

Merged
merged 1 commit into from Dec 28, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/middleware/cookieSession.js
Expand Up @@ -13,7 +13,7 @@ var utils = require('./../utils')
, Cookie = require('./session/cookie') , Cookie = require('./session/cookie')
, debug = require('debug')('connect:cookieSession') , debug = require('debug')('connect:cookieSession')
, signature = require('cookie-signature') , signature = require('cookie-signature')
, crc16 = require('crc').crc16; , crc32 = require('buffer-crc32');


/** /**
* Cookie Session: * Cookie Session:
Expand Down Expand Up @@ -71,7 +71,7 @@ module.exports = function cookieSession(options){
if (rawCookie) { if (rawCookie) {
var unsigned = utils.parseSignedCookie(rawCookie, secret); var unsigned = utils.parseSignedCookie(rawCookie, secret);
if (unsigned) { if (unsigned) {
var originalHash = crc16(unsigned); var originalHash = crc32.signed(unsigned);
req.session = utils.parseJSONCookie(unsigned) || {}; req.session = utils.parseJSONCookie(unsigned) || {};
} }
} }
Expand Down Expand Up @@ -101,7 +101,7 @@ module.exports = function cookieSession(options){
var val = 'j:' + JSON.stringify(req.session); var val = 'j:' + JSON.stringify(req.session);


// compare hashes, no need to set-cookie if unchanged // compare hashes, no need to set-cookie if unchanged
if (originalHash == crc16(val)) return debug('unmodified session'); if (originalHash == crc32.signed(val)) return debug('unmodified session');


// set-cookie // set-cookie
val = 's:' + signature.sign(val, secret); val = 's:' + signature.sign(val, secret);
Expand Down
4 changes: 2 additions & 2 deletions lib/middleware/session.js
Expand Up @@ -18,7 +18,7 @@ var Session = require('./session/session')
, Store = require('./session/store') , Store = require('./session/store')
, utils = require('./../utils') , utils = require('./../utils')
, parse = utils.parseUrl , parse = utils.parseUrl
, crc16 = require('crc').crc16; , crc32 = require('buffer-crc32');


// environment // environment


Expand Down Expand Up @@ -346,7 +346,7 @@ function session(options){
*/ */


function hash(sess) { function hash(sess) {
return crc16(JSON.stringify(sess, function(key, val){ return crc32.signed(JSON.stringify(sess, function(key, val){
if ('cookie' != key) return val; if ('cookie' != key) return val;
})); }));
} }
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -9,7 +9,7 @@
"qs": "0.5.1", "qs": "0.5.1",
"formidable": "1.0.11", "formidable": "1.0.11",
"cookie-signature": "0.0.1", "cookie-signature": "0.0.1",
"crc": "0.2.0", "buffer-crc32": "0.1.1",
"cookie": "0.0.5", "cookie": "0.0.5",
"bytes": "0.0.1", "bytes": "0.0.1",
"send": "0.1.0", "send": "0.1.0",
Expand Down