Skip to content

Commit

Permalink
fix(serializer): do not use checkKeys for $clusterTime
Browse files Browse the repository at this point in the history
Fixes NODE-1409
  • Loading branch information
kvwalker authored and Sophie Saskin committed Aug 8, 2018
1 parent 5acdebf commit cbb4724
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/parser/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const constants = require('../constants');
const normalizedFunctionString = require('./utils').normalizedFunctionString;

const regexp = /\x00/; // eslint-disable-line no-control-regex
const ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']);

// To ensure that 0.4 of node works correctly
const isDate = function isDate(d) {
Expand Down Expand Up @@ -785,7 +786,7 @@ function serializeInto(
const type = typeof value;

// Check the key and throw error if it's illegal
if (key !== '$db' && key !== '$ref' && key !== '$id') {
if (!ignoreKeys.has(key)) {
if (key.match(regexp) != null) {
// The BSON spec doesn't allow keys with null bytes because keys are
// null-terminated.
Expand Down Expand Up @@ -885,7 +886,7 @@ function serializeInto(
const type = typeof value;

// Check the key and throw error if it's illegal
if (key !== '$db' && key !== '$ref' && key !== '$id') {
if (!ignoreKeys.has(key)) {
if (key.match(regexp) != null) {
// The BSON spec doesn't allow keys with null bytes because keys are
// null-terminated.
Expand Down

0 comments on commit cbb4724

Please sign in to comment.