File tree Expand file tree Collapse file tree 11 files changed +68
-222
lines changed
Expand file tree Collapse file tree 11 files changed +68
-222
lines changed Original file line number Diff line number Diff line change @@ -55,9 +55,6 @@ export interface BSONSerializeOptions
5555 > {
5656 /** Return BSON filled buffers from operations */
5757 raw ?: boolean ;
58-
59- /** Enable utf8 validation when deserializing BSON documents. Defaults to true. */
60- enableUtf8Validation ?: boolean ;
6158}
6259
6360export function pluckBSONSerializeOptions ( options : BSONSerializeOptions ) : BSONSerializeOptions {
@@ -69,8 +66,7 @@ export function pluckBSONSerializeOptions(options: BSONSerializeOptions): BSONSe
6966 serializeFunctions,
7067 ignoreUndefined,
7168 bsonRegExp,
72- raw,
73- enableUtf8Validation
69+ raw
7470 } = options ;
7571 return {
7672 fieldsAsRaw,
@@ -80,8 +76,7 @@ export function pluckBSONSerializeOptions(options: BSONSerializeOptions): BSONSe
8076 serializeFunctions,
8177 ignoreUndefined,
8278 bsonRegExp,
83- raw,
84- enableUtf8Validation
79+ raw
8580 } ;
8681}
8782
@@ -104,8 +99,6 @@ export function resolveBSONOptions(
10499 ignoreUndefined : options ?. ignoreUndefined ?? parentOptions ?. ignoreUndefined ?? false ,
105100 bsonRegExp : options ?. bsonRegExp ?? parentOptions ?. bsonRegExp ?? false ,
106101 serializeFunctions : options ?. serializeFunctions ?? parentOptions ?. serializeFunctions ?? false ,
107- fieldsAsRaw : options ?. fieldsAsRaw ?? parentOptions ?. fieldsAsRaw ?? { } ,
108- enableUtf8Validation :
109- options ?. enableUtf8Validation ?? parentOptions ?. enableUtf8Validation ?? true
102+ fieldsAsRaw : options ?. fieldsAsRaw ?? parentOptions ?. fieldsAsRaw ?? { }
110103 } ;
111104}
Original file line number Diff line number Diff line change @@ -469,6 +469,8 @@ export interface MessageHeader {
469469export interface OpResponseOptions extends BSONSerializeOptions {
470470 raw ?: boolean ;
471471 documentsReturnedIn ?: string | null ;
472+ // For now we use this internally to only prevent writeErrors from crashing the driver
473+ validation ?: { utf8 : { writeErrors : boolean } } ;
472474}
473475
474476/** @internal */
@@ -837,7 +839,7 @@ export class BinMsg {
837839 const promoteValues = options . promoteValues ?? this . opts . promoteValues ;
838840 const promoteBuffers = options . promoteBuffers ?? this . opts . promoteBuffers ;
839841 const bsonRegExp = options . bsonRegExp ?? this . opts . bsonRegExp ;
840- const validation = this . parseBsonSerializationOptions ( options ) ;
842+ const validation = options . validation ?? { utf8 : { writeErrors : false } } ;
841843
842844 // Set up the options
843845 const bsonOptions : BSONSerializeOptions = {
@@ -874,14 +876,4 @@ export class BinMsg {
874876
875877 this . parsed = true ;
876878 }
877-
878- parseBsonSerializationOptions ( { enableUtf8Validation } : BSONSerializeOptions ) : {
879- utf8 : { writeErrors : false } | false ;
880- } {
881- if ( enableUtf8Validation === false ) {
882- return { utf8 : false } ;
883- }
884-
885- return { utf8 : { writeErrors : false } } ;
886- }
887879}
Original file line number Diff line number Diff line change @@ -787,8 +787,6 @@ function write(
787787 promoteValues : typeof options . promoteValues === 'boolean' ? options . promoteValues : true ,
788788 promoteBuffers : typeof options . promoteBuffers === 'boolean' ? options . promoteBuffers : false ,
789789 bsonRegExp : typeof options . bsonRegExp === 'boolean' ? options . bsonRegExp : false ,
790- enableUtf8Validation :
791- typeof options . enableUtf8Validation === 'boolean' ? options . enableUtf8Validation : true ,
792790 raw : typeof options . raw === 'boolean' ? options . raw : false ,
793791 started : 0
794792 } ;
Original file line number Diff line number Diff line change @@ -45,9 +45,7 @@ export function applyCommonQueryOptions(
4545 promoteLongs : typeof options . promoteLongs === 'boolean' ? options . promoteLongs : true ,
4646 promoteValues : typeof options . promoteValues === 'boolean' ? options . promoteValues : true ,
4747 promoteBuffers : typeof options . promoteBuffers === 'boolean' ? options . promoteBuffers : false ,
48- bsonRegExp : typeof options . bsonRegExp === 'boolean' ? options . bsonRegExp : false ,
49- enableUtf8Validation :
50- typeof options . enableUtf8Validation === 'boolean' ? options . enableUtf8Validation : true
48+ bsonRegExp : typeof options . bsonRegExp === 'boolean' ? options . bsonRegExp : false
5149 } ) ;
5250
5351 if ( options . session ) {
Original file line number Diff line number Diff line change @@ -688,7 +688,6 @@ export const OPTIONS = {
688688 } ) ;
689689 }
690690 } ,
691- enableUtf8Validation : { type : 'boolean' , default : true } ,
692691 family : {
693692 transform ( { name, values : [ value ] } ) : 4 | 6 {
694693 const transformValue = getInt ( name , value ) ;
Original file line number Diff line number Diff line change @@ -73,7 +73,6 @@ const DB_OPTIONS_ALLOW_LIST = [
7373 'promoteBuffers' ,
7474 'promoteLongs' ,
7575 'bsonRegExp' ,
76- 'enableUtf8Validation' ,
7776 'promoteValues' ,
7877 'compression' ,
7978 'retryWrites'
Original file line number Diff line number Diff line change @@ -27,8 +27,7 @@ const ILLEGAL_COMMAND_FIELDS = new Set([
2727 'promoteBuffers' ,
2828 'bsonRegExp' ,
2929 'serializeFunctions' ,
30- 'ignoreUndefined' ,
31- 'enableUtf8Validation'
30+ 'ignoreUndefined'
3231] ) ;
3332
3433/** @public
Original file line number Diff line number Diff line change @@ -33,7 +33,6 @@ const exclusionList = [
3333 'bsonRegExp' ,
3434 'serializeFunctions' ,
3535 'ignoreUndefined' ,
36- 'enableUtf8Validation' ,
3736 'scope' // this option is reformatted thus exclude the original
3837] ;
3938
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ type PermittedBSONOptionKeys =
2121 | 'promoteValues'
2222 | 'bsonRegExp'
2323 | 'fieldsAsRaw'
24- | 'enableUtf8Validation'
2524 | 'raw' ;
2625
2726const keys = null as unknown as PermittedBSONOptionKeys ;
You can’t perform that action at this time.
0 commit comments