Permalink
Browse files

* Fixed some unsafe for(... in ...) loops that do not take extensions to

  built-in type prototypes into account (which shop up in such loops).
  Added .hasOwnProperty checks there, also replaced parameter iteration
  in commands.js to a for-loop with a counter, rather than for-in.
* Added `close` method to WebSQL interface
  • Loading branch information...
1 parent 73849ce commit 702a56b434afdab57cb9ee2a167747ddbde4b49e @zefhemel zefhemel committed Jul 12, 2010
Showing with 15 additions and 8 deletions.
  1. +9 −6 mysql/commands.js
  2. +5 −2 mysql/constants.js
  3. +1 −0 mysql/websql.js
View
@@ -115,7 +115,10 @@ function cmd(handlers)
// mixin all handlers
for (h in handlers)
{
- this[h] = handlers[h];
+ if(handlers.hasOwnProperty(h))
+ {
+ this[h] = handlers[h];
+ }
}
// delegate to private EventEmitter member
@@ -371,15 +374,15 @@ function execute(sql, parameters)
// todo: set types only on first call
packet.add('\u0001');
// todo: add numeric/datetime serialisers
- for (var p in parameters)
+ for (var i = 0; i < parameters.length; i++)
{
- if (parameters[p] != null)
+ if (parameters[i] != null)
packet.int2(types.MYSQL_TYPE_VAR_STRING);
}
- for (var p in parameters)
+ for (var i = 0; i < parameters.length; i++)
{
- if (parameters[p] != null)
- packet.lcstring(parameters[p].toString());
+ if (parameters[i] != null)
+ packet.lcstring(parameters[i].toString());
}
}
this.write( packet );
View
@@ -84,6 +84,9 @@ exports.type_names = {};
for (var tname in exports.types)
{
- var type = exports.types[tname];
- exports.type_names[type] = tname;
+ if(exports.types.hasOwnProperty(tname) )
+ {
+ var type = exports.types[tname];
+ exports.type_names[type] = tname;
+ }
}
View
@@ -55,5 +55,6 @@ exports.openDatabase = function(db, user, password)
commit.sql = t.clean ? "COMMIT" : "ROLLBACK"
});
}
+ webdb.close = function() { connection.close(); };
return webdb;
}

0 comments on commit 702a56b

Please sign in to comment.