Compare commits

...

30 Commits
1.0.0 ... 1.0.4

Author SHA1 Message Date
Guillermo Rauch
475909e642 Release 1.0.4 2014-06-02 20:08:33 -07:00
Guillermo Rauch
95acec8b94 package: bump socket.io-client 2014-06-02 20:07:07 -07:00
Guillermo Rauch
1bbc3951bd Release 1.0.3 2014-05-31 18:34:50 -07:00
Guillermo Rauch
039eed2c2a package: bump socket.io-client 2014-05-31 09:53:25 -07:00
Guillermo Rauch
6de022b180 Merge pull request #1565 from kevin-roark/add/binary-ack
Add/binary ack
2014-05-31 09:50:19 -07:00
Guillermo Rauch
a06331d29f travis fix 2014-05-30 21:37:22 -07:00
Guillermo Rauch
e639685370 fix travis 2014-05-30 21:23:55 -07:00
Guillermo Rauch
1f2e681ce2 package: bump socket.io-parser for binary ack fix 2014-05-30 21:11:57 -07:00
Kevin Roark
397944fcbe big file tests 2014-05-30 20:40:44 -07:00
Kevin Roark
27dada65b9 distinction between ACK and BINARY_ACK 2014-05-30 18:42:23 -07:00
Guillermo Rauch
99f1ac9aae Merge pull request #1563 from rase-/fix/no-disconnect-fired-for-nsp
Fix namespace iterator in disconnect
2014-05-30 16:40:59 -07:00
Tony Kovanen
ee8d0fbae0 Fix namespace iterator in disconnect 2014-05-31 02:25:28 +03:00
Guillermo Rauch
8e08a6d419 Merge pull request #1562 from rase-/add/utf8-tests
Add test case for emitting multibyte chars
2014-05-30 15:48:34 -07:00
Tony Kovanen
318ae87f50 Add test case for emitting multibyte chars 2014-05-31 01:45:31 +03:00
Guillermo Rauch
2c1b61148d Merge branch 'master' of github.com:automattic/socket.io 2014-05-30 14:14:12 -07:00
Guillermo Rauch
507054c0a8 package: bump engine.io for utf8 binary fix 2014-05-30 14:09:54 -07:00
Tony Kovanen
dfceb006d7 Merge pull request #1554 from grant/master
Fix xss vulnerability in example chat app
2014-05-30 12:15:12 +03:00
Grant Timmerman
4d83456f74 Fix xss vulnerability in example chat app 2014-05-30 02:03:33 -07:00
Tony Kovanen
201aad83b1 Merge pull request #1540 from grant/master
Make chat example wrap long words (no overflow)
2014-05-30 12:02:15 +03:00
Grant Timmerman
72eb61d01f Make chat example wrap long words (no overflow) 2014-05-30 01:44:27 -07:00
Tony Kovanen
163a2a696e Merge pull request #1543 from mohnish/patch-1
Remove obsolete message from README file
2014-05-29 21:33:36 +03:00
Guillermo Rauch
199a479ebc Merge pull request #1545 from overra/patch-1
Use cleanInput() on incoming messages
2014-05-28 20:47:20 -07:00
Guillermo Rauch
d383ff9662 Merge pull request #1546 from hiddenmin/patch-1
Update Readme.md
2014-05-28 19:42:39 -07:00
Amin Cheloh
416b550189 Update Readme.md
socket.io-adapter link
2014-05-29 09:41:37 +07:00
Adam Snodgrass
536b338a01 Use cleanInput() on incoming messages
This prevents XSS if one were to send messages using socket.io from the console.
2014-05-28 20:35:24 -05:00
Mohnish Thallavajhula
a06ae10895 Remove obsolete message from README file 2014-05-28 17:10:50 -07:00
Guillermo Rauch
35a85084b1 Release 1.0.2 2014-05-28 13:24:59 -07:00
Guillermo Rauch
0c2b44a846 package: bump parser for windows fix 2014-05-28 13:23:51 -07:00
Guillermo Rauch
0f6ee2dbd9 travis 2014-05-28 12:56:10 -07:00
Guillermo Rauch
68ac0d6d24 Release 1.0.1 2014-05-28 10:32:31 -07:00
10 changed files with 174222 additions and 25 deletions

View File

@@ -1,4 +1,27 @@
1.0.4 / 2014-06-02
==================
* package: bump socket.io-client
1.0.3 / 2014-05-31
==================
* package: bump `socket.io-client`
* package: bump `socket.io-parser` for binary ACK fix
* package: bump `engine.io` for binary UTF8 fix
* example: fix XSS in chat example
1.0.2 / 2014-05-28
==================
* package: bump `socket.io-parser` for windows fix
1.0.1 / 2014-05-28
==================
* bump due to bad npm tag
1.0.0 / 2014-05-28
==================

View File

@@ -1,10 +1,7 @@
### This Readme corresponds to the upcoming 1.0 release. Please refer to http://socket.io for the current 0.9.x documentation.
<hr />
# socket.io
[![Build Status](https://secure.travis-ci.org/LearnBoost/socket.io.png)](http://travis-ci.org/LearnBoost/socket.io)
[![Build Status](https://secure.travis-ci.org/Automattic/socket.io.png)](http://travis-ci.org/Automattic/socket.io)
[![NPM version](https://badge.fury.io/js/socket.io.png)](http://badge.fury.io/js/socket.io)
## How to use
@@ -129,7 +126,7 @@ server.listen(3000);
Sets the adapter `v`. Defaults to an instance of the `Adapter` that
ships with socket.io which is memory based. See
[socket.io-adapter](https://github.com/learnboost/socket.io-adapter).
[socket.io-adapter](https://github.com/Automattic/socket.io-adapter).
If no arguments are supplied this method returns the current value.
@@ -288,7 +285,7 @@ server.listen(3000);
The mechanics of joining rooms are handled by the `Adapter`
that has been configured (see `Server#adapter` above), defaulting to
[socket.io-adapter](https://github.com/socket.io/socket.io-adapter).
[socket.io-adapter](https://github.com/Automattic/socket.io-adapter).
### Socket#leave(name:String[, fn:Function]):Socket
@@ -299,7 +296,7 @@ server.listen(3000);
The mechanics of leaving rooms are handled by the `Adapter`
that has been configured (see `Server#adapter` above), defaulting to
[socket.io-adapter](https://github.com/socket.io/socket.io-adapter).
[socket.io-adapter](https://github.com/Automattic/socket.io-adapter).
### Socket#to(room:String):Socket
### Socket#in(room:String):Socket

View File

@@ -70,8 +70,8 @@ $(function() {
// Log a message
function log (message, options) {
var el = '<li class="log">' + message + '</li>';
addMessageElement(el, options);
var $el = $('<li>').addClass('log').text(message);
addMessageElement($el, options);
}
// Adds the visual chat message to the message list
@@ -84,16 +84,17 @@ $(function() {
$typingMessages.remove();
}
var colorStyle = 'style="color:' + getUsernameColor(data.username) + '"';
var usernameDiv = '<span class="username"' + colorStyle + '>' +
data.username + '</span>';
var messageBodyDiv = '<span class="messageBody">' +
data.message + '</span>';
var $usernameDiv = $('<span class="username"/>')
.text(data.username)
.css('color', getUsernameColor(data.username));
var $messageBodyDiv = $('<span class="messageBody">')
.text(data.message);
var typingClass = data.typing ? 'typing' : '';
var messageDiv = '<li class="message ' + typingClass + '">' +
usernameDiv + messageBodyDiv + '</li>';
var $messageDiv = $(messageDiv).data('username', data.username);
var $messageDiv = $('<li class="message"/>')
.data('username', data.username)
.addClass(typingClass)
.append($usernameDiv, $messageBodyDiv);
addMessageElement($messageDiv, options);
}
@@ -145,7 +146,7 @@ $(function() {
// Prevents input from having injected markup
function cleanInput (input) {
return $('<div/>').text(input).html() || input;
return $('<div/>').text(input).text();
}
// Updates the typing event

View File

@@ -25,6 +25,7 @@ html, body {
ul {
list-style: none;
word-wrap: break-word;
}
/* Pages */

View File

@@ -199,9 +199,10 @@ Client.prototype.onclose = function(reason){
this.destroy();
// `nsps` and `sockets` are cleaned up seamlessly
this.sockets.forEach(function(socket){
var socket;
while (socket = this.sockets.shift()) {
socket.onclose(reason);
});
}
this.decoder.destroy(); // clean up decoder
};

View File

@@ -293,6 +293,10 @@ Socket.prototype.onpacket = function(packet){
this.onack(packet);
break;
case parser.BINARY_ACK:
this.onack(packet);
break;
case parser.DISCONNECT:
this.ondisconnect();
break;
@@ -336,9 +340,11 @@ Socket.prototype.ack = function(id){
if (sent) return;
var args = Array.prototype.slice.call(arguments);
debug('sending ack %j', args);
var type = hasBin(args) ? parser.BINARY_ACK : parser.ACK;
self.packet({
id: id,
type: parser.ACK,
type: type,
data: args
});
};

View File

@@ -1,6 +1,6 @@
{
"name": "socket.io",
"version": "1.0.0",
"version": "1.0.4",
"description": "node.js realtime framework server",
"keywords": [
"realtime",
@@ -19,9 +19,9 @@
"test": "make test"
},
"dependencies": {
"engine.io": "1.2.1",
"socket.io-parser": "2.1.4",
"socket.io-client": "1.0.0",
"engine.io": "1.2.2",
"socket.io-parser": "2.2.0",
"socket.io-client": "1.0.4",
"socket.io-adapter": "0.2.0",
"has-binary-data": "0.1.1",
"debug": "0.7.4"

BIN
test/fixtures/big.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 MiB

174066
test/fixtures/big.json vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -395,6 +395,33 @@ describe('socket.io', function(){
}
});
});
it('should disconnect both default and custom namespace upon disconnect', function(done){
var srv = http();
var sio = io(srv);
srv.listen(function(){
var lolcats = client(srv, '/lolcats');
var total = 2;
var totald = 2;
var s;
sio.of('/', function(socket){
socket.on('disconnect', function(reason){
--totald || done();
});
--total || close();
});
sio.of('/lolcats', function(socket){
s = socket;
socket.on('disconnect', function(reason){
--totald || done();
});
--total || close();
});
function close(){
s.disconnect(true);
}
});
});
});
});
@@ -446,6 +473,28 @@ describe('socket.io', function(){
});
});
it('should emit events with utf8 multibyte character', function(done) {
var srv = http();
var sio = io(srv);
srv.listen(function(){
var socket = client(srv);
var i = 0;
socket.on('hoot', function(a){
expect(a).to.be('utf8 — string');
i++;
if (3 == i) {
done();
}
});
sio.on('connection', function(s){
s.emit('hoot', 'utf8 — string');
s.emit('hoot', 'utf8 — string');
s.emit('hoot', 'utf8 — string');
});
});
});
it('should emit events with binary data', function(done){
var srv = http();
var sio = io(srv);
@@ -746,6 +795,59 @@ describe('socket.io', function(){
});
});
});
it('should handle very large json', function(done){
this.timeout();
var srv = http();
var sio = io(srv);
var received = 0;
srv.listen(function(){
var socket = client(srv);
socket.on('big', function(a){
expect(Buffer.isBuffer(a.json)).to.be(false);
if (++received == 3)
done();
else
socket.emit('big', a);
});
sio.on('connection', function(s){
fs.readFile(join(__dirname, 'fixtures', 'big.json'), function(err, data){
if (err) return done(err);
data = JSON.parse(data);
s.emit('big', {hello: 'friend', json: data});
});
s.on('big', function(a){
s.emit('big', a);
});
});
});
});
it('should handle very large binary data', function(done){
var srv = http();
var sio = io(srv);
var received = 0;
srv.listen(function(){
var socket = client(srv);
socket.on('big', function(a){
expect(Buffer.isBuffer(a.image)).to.be(true);
if (++received == 3)
done();
else
socket.emit('big', a);
});
sio.on('connection', function(s){
fs.readFile(join(__dirname, 'fixtures', 'big.jpg'), function(err, data){
if (err) return done(err);
s.emit('big', {hello: 'friend', image: data});
});
s.on('big', function(a){
expect(Buffer.isBuffer(a.image)).to.be(true);
s.emit('big', a);
});
});
});
});
});
describe('messaging many', function(){