Skip to content

Commit 773aa30

Browse files
committed
adding hasOwnProperty header protection
1 parent 98f04fb commit 773aa30

File tree

3 files changed

+69
-15
lines changed

3 files changed

+69
-15
lines changed

lib/frame.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ Frame.prototype.as_string = function() {
7878
body = this.body;
7979

8080
for (var header in headers) {
81-
header_strs.push(header + ':' + headers[header]);
81+
if (headers.hasOwnProperty(header)) {
82+
header_strs.push(header + ':' + headers[header]);
83+
}
8284
}
8385

8486
frame += command + "\n";

package.json

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,49 @@
11
{
2-
"name" : "stomp",
2+
"name": "eyeos-stomp",
33
"description": "Implementation of the STOMP protocol in node.js",
4-
"keywords": [ "STOMP", "messaging", "queue", "protocol" ],
5-
"version": "v0.1.1",
4+
"keywords": [
5+
"STOMP",
6+
"messaging",
7+
"queue",
8+
"protocol"
9+
],
10+
"version": "0.1.2",
611
"homepage": "https://github.com/benjaminws/stomp-js",
7-
"author": "Benjamin W. Smith <benjaminws@just-another.net>",
8-
"contributors" : [ "rofflwaffls@gmail.com" ],
9-
"main" : "lib/stomp",
10-
"repository" : {
11-
"type" : "git",
12-
"url" : "https://benjaminws@github.com/benjaminws/stomp-js.git"
12+
"author": {
13+
"name": "Benjamin W. Smith",
14+
"email": "benjaminws@just-another.net"
1315
},
14-
"directories" : {
16+
"contributors": [
17+
{
18+
"name": "rofflwaffls@gmail.com"
19+
},
20+
{
21+
"name": "eyeos@eyeos.com"
22+
}
23+
],
24+
"main": "lib/stomp",
25+
"repository": {
26+
"type": "git",
27+
"url": "https://github.com/eyeos2/stomp-js.git"
28+
},
29+
"directories": {
1530
"lib": "./lib",
1631
"examples": "./examples"
1732
},
18-
"licenses" : [{
19-
"type" : "BSD",
20-
"url" : "https://github.com/benjaminws/stomp-js/raw/master/LICENSE"
21-
}]
33+
"devDependencies": {
34+
"nodeunit": "0.9.0"
35+
},
36+
"licenses": [
37+
{
38+
"type": "BSD",
39+
"url": "https://github.com/benjaminws/stomp-js/raw/master/LICENSE"
40+
}
41+
],
42+
"readme": "stomp-js\n========\n\n## Overview\n\nAn exercise with node.js to implement the STOMP protocol.\n\nFor documentation see http://benjaminws.github.com/stomp-js/\n\n## Installation\n\n`npm install stomp`\n\n`git clone https://benjaminws@github.com/benjaminws/stomp-js.git`\n\n## Examples\n\n### Consumer\n\nSee examples/stomp-consumer.js\n\n### Producer\n\nSee examples/stomp-producer.js\n\n### Producer with Transaction Support\n\nSee examples/stomp-producer-txn.js\n\n### Contributors\n\nrofflwaffls -at- gmail.com\n",
43+
"readmeFilename": "README.md",
44+
"bugs": {
45+
"url": "https://github.com/eyeos2/stomp-js/issues"
46+
},
47+
"_id": "eyeos-stomp@0.1.2",
48+
"_from": "eyeos-stomp@*"
2249
}

test/test-frame.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,28 @@ module.exports['connect'] = testCase({
6363
test.done();
6464
}
6565
});
66+
67+
module.exports['as_string'] = testCase({
68+
'should not add extended properties from prototype': function(test) {
69+
Object.prototype.foo = 'bar';
70+
var Frame = require('../lib/frame.js').Frame;
71+
var frame = new Frame();
72+
frame.build_frame({
73+
command: 'CONNECT',
74+
headers: {
75+
'login': 'somelogin',
76+
'passcode': 'somepass'
77+
}
78+
});
79+
80+
var frame_text = frame.as_string();
81+
var foo_in_frame = frame_text.indexOf('foo') !== -1;
82+
test.equal(
83+
foo_in_frame,
84+
false,
85+
"Frame should not contain the extended property foo"
86+
);
87+
test.done()
88+
delete Object.prototype.foo;
89+
}
90+
});

0 commit comments

Comments
 (0)