Skip to content

Commit

Permalink
Added null escaping
Browse files Browse the repository at this point in the history
Added failing null character escaping test
Fixes geddy#245
  • Loading branch information
Dan Finlay authored and danfinlay committed Feb 6, 2015
1 parent 63833b6 commit 47c61d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/datatypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ _escape = function (s, type) {
// Scrub input for basic SQL injection protection
case 'sql':
ret = s.replace(/'/g, "''");
ret = ret.replace('\u0000', ' ');
break;
// Backslash-esc single quotes for use in M/R JS sourcecode str
case 'js':
Expand Down
9 changes: 9 additions & 0 deletions test/integration/adapters/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,15 @@ tests = {
});
});
}

, 'test escaping null characters': function (next) {
var person = model.Person.create({title: 'test \u0000!'});
person.save(function (err, data) {
if (err) { throw err; }
next();
});
}

};

module.exports = tests;

0 comments on commit 47c61d3

Please sign in to comment.