From 47c61d3f6a30e07d7de51dc37c224ff54912a374 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 6 Feb 2015 10:33:30 -0800 Subject: [PATCH] Added null escaping Added failing null character escaping test Fixes #245 --- lib/datatypes.js | 1 + test/integration/adapters/shared.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/datatypes.js b/lib/datatypes.js index 80d79107..f212f770 100644 --- a/lib/datatypes.js +++ b/lib/datatypes.js @@ -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': diff --git a/test/integration/adapters/shared.js b/test/integration/adapters/shared.js index 11f5229b..f003c25b 100644 --- a/test/integration/adapters/shared.js +++ b/test/integration/adapters/shared.js @@ -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;