Skip to content

Commit b4e3fe7

Browse files
committed
FIX leak detected: window
1 parent 740aa63 commit b4e3fe7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

php-unserialize.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Wrapper for nodejs/browser compat
2-
(function (exports) {
2+
(function (window, exports) {
33

44
// Public API
55
exports.unserialize = unserialize;
@@ -38,7 +38,6 @@ function unserialize (data) {
3838
// * returns 1: ['Kevin', 'van', 'Zonneveld']
3939
// * example 2: unserialize('a:3:{s:9:"firstName";s:5:"Kevin";s:7:"midName";s:3:"van";s:7:"surName";s:9:"Zonneveld";}');
4040
// * returns 2: {firstName: 'Kevin', midName: 'van', surName: 'Zonneveld'}
41-
if (!this.window) this.window = this;
4241
var that = this,
4342
utf8Overhead = function (chr) {
4443
// http://phpjs.org/functions/unserialize:571#comment_95906
@@ -52,7 +51,7 @@ function unserialize (data) {
5251
return 2;
5352
},
5453
error = function (type, msg, filename, line) {
55-
throw new that.window[type](msg, filename, line);
54+
throw new window[type](msg, filename, line);
5655
},
5756
read_until = function (data, offset, stopchr) {
5857
var i = 2, buf = [], chr = data.slice(offset, offset + 1);
@@ -207,4 +206,4 @@ function unserializeSession (input) {
207206
}
208207

209208
// /Wrapper
210-
})((typeof window !== 'undefined') ? (window.PHPUnserialize = {}) : exports);
209+
})((typeof window === 'undefined') ? global : window, (typeof window === 'undefined') ? exports : (window.PHPUnserialize = {}));

0 commit comments

Comments
 (0)