Skip to content

Commit

Permalink
test(NODE-3447): serialization of BSON with embedded null bytes in st…
Browse files Browse the repository at this point in the history
…rings (#460)
  • Loading branch information
nbbeeken authored Sep 17, 2021
1 parent 71c6513 commit dea5e13
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
4 changes: 4 additions & 0 deletions test/node/specs/bson-corpus/document.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
{
"description": "Invalid subdocument: bad string length in field",
"bson": "1C00000003666F6F001200000002626172000500000062617A000000"
},
{
"description": "Null byte in sub-document key",
"bson": "150000000378000D00000010610000010000000000"
}
]
}
4 changes: 2 additions & 2 deletions test/node/specs/bson-corpus/regex.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
],
"decodeErrors": [
{
"description": "embedded null in pattern",
"description": "Null byte in pattern string",
"bson": "0F0000000B610061006300696D0000"
},
{
"description": "embedded null in flags",
"description": "Null byte in flags string",
"bson": "100000000B61006162630069006D0000"
}
]
Expand Down
25 changes: 22 additions & 3 deletions test/node/specs/bson-corpus/top.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
{
"description": "Document truncated mid-key",
"bson": "1200000002666F"
},
{
"description": "Null byte in document key",
"bson": "0D000000107800000100000000"
}
],
"parseErrors": [
Expand All @@ -92,11 +96,11 @@
},
{
"description": "Bad $regularExpression (pattern is number, not string)",
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": 42, \"$options\" : \"\"}}}"
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": 42, \"options\" : \"\"}}}"
},
{
"description": "Bad $regularExpression (options are number, not string)",
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": \"a\", \"$options\" : 0}}}"
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": \"a\", \"options\" : 0}}}"
},
{
"description" : "Bad $regularExpression (missing pattern field)",
Expand Down Expand Up @@ -241,7 +245,22 @@
{
"description": "Bad DBpointer (extra field)",
"string": "{\"a\": {\"$dbPointer\": {\"a\": {\"$numberInt\": \"1\"}, \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}, \"c\": {\"$numberInt\": \"2\"}, \"$ref\": \"b\"}}}"
},
{
"description" : "Null byte in document key",
"string" : "{\"a\\u0000\": 1 }"
},
{
"description" : "Null byte in sub-document key",
"string" : "{\"a\" : {\"b\\u0000\": 1 }}"
},
{
"description": "Null byte in $regularExpression pattern",
"string": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"b\\u0000\", \"options\" : \"i\"}}}"
},
{
"description": "Null byte in $regularExpression options",
"string": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"b\", \"options\" : \"i\\u0000\"}}}"
}

]
}

0 comments on commit dea5e13

Please sign in to comment.