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
55
55
> {
56
56
/** Return BSON filled buffers from operations */
57
57
raw ?: boolean ;
58
-
59
- /** Enable utf8 validation when deserializing BSON documents. Defaults to true. */
60
- enableUtf8Validation ?: boolean ;
61
58
}
62
59
63
60
export function pluckBSONSerializeOptions ( options : BSONSerializeOptions ) : BSONSerializeOptions {
@@ -69,8 +66,7 @@ export function pluckBSONSerializeOptions(options: BSONSerializeOptions): BSONSe
69
66
serializeFunctions,
70
67
ignoreUndefined,
71
68
bsonRegExp,
72
- raw,
73
- enableUtf8Validation
69
+ raw
74
70
} = options ;
75
71
return {
76
72
fieldsAsRaw,
@@ -80,8 +76,7 @@ export function pluckBSONSerializeOptions(options: BSONSerializeOptions): BSONSe
80
76
serializeFunctions,
81
77
ignoreUndefined,
82
78
bsonRegExp,
83
- raw,
84
- enableUtf8Validation
79
+ raw
85
80
} ;
86
81
}
87
82
@@ -104,8 +99,6 @@ export function resolveBSONOptions(
104
99
ignoreUndefined : options ?. ignoreUndefined ?? parentOptions ?. ignoreUndefined ?? false ,
105
100
bsonRegExp : options ?. bsonRegExp ?? parentOptions ?. bsonRegExp ?? false ,
106
101
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 ?? { }
110
103
} ;
111
104
}
Original file line number Diff line number Diff line change @@ -469,6 +469,8 @@ export interface MessageHeader {
469
469
export interface OpResponseOptions extends BSONSerializeOptions {
470
470
raw ?: boolean ;
471
471
documentsReturnedIn ?: string | null ;
472
+ // For now we use this internally to only prevent writeErrors from crashing the driver
473
+ validation ?: { utf8 : { writeErrors : boolean } } ;
472
474
}
473
475
474
476
/** @internal */
@@ -837,7 +839,7 @@ export class BinMsg {
837
839
const promoteValues = options . promoteValues ?? this . opts . promoteValues ;
838
840
const promoteBuffers = options . promoteBuffers ?? this . opts . promoteBuffers ;
839
841
const bsonRegExp = options . bsonRegExp ?? this . opts . bsonRegExp ;
840
- const validation = this . parseBsonSerializationOptions ( options ) ;
842
+ const validation = options . validation ?? { utf8 : { writeErrors : false } } ;
841
843
842
844
// Set up the options
843
845
const bsonOptions : BSONSerializeOptions = {
@@ -874,14 +876,4 @@ export class BinMsg {
874
876
875
877
this . parsed = true ;
876
878
}
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
- }
887
879
}
Original file line number Diff line number Diff line change @@ -787,8 +787,6 @@ function write(
787
787
promoteValues : typeof options . promoteValues === 'boolean' ? options . promoteValues : true ,
788
788
promoteBuffers : typeof options . promoteBuffers === 'boolean' ? options . promoteBuffers : false ,
789
789
bsonRegExp : typeof options . bsonRegExp === 'boolean' ? options . bsonRegExp : false ,
790
- enableUtf8Validation :
791
- typeof options . enableUtf8Validation === 'boolean' ? options . enableUtf8Validation : true ,
792
790
raw : typeof options . raw === 'boolean' ? options . raw : false ,
793
791
started : 0
794
792
} ;
Original file line number Diff line number Diff line change @@ -45,9 +45,7 @@ export function applyCommonQueryOptions(
45
45
promoteLongs : typeof options . promoteLongs === 'boolean' ? options . promoteLongs : true ,
46
46
promoteValues : typeof options . promoteValues === 'boolean' ? options . promoteValues : true ,
47
47
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
51
49
} ) ;
52
50
53
51
if ( options . session ) {
Original file line number Diff line number Diff line change @@ -688,7 +688,6 @@ export const OPTIONS = {
688
688
} ) ;
689
689
}
690
690
} ,
691
- enableUtf8Validation : { type : 'boolean' , default : true } ,
692
691
family : {
693
692
transform ( { name, values : [ value ] } ) : 4 | 6 {
694
693
const transformValue = getInt ( name , value ) ;
Original file line number Diff line number Diff line change @@ -73,7 +73,6 @@ const DB_OPTIONS_ALLOW_LIST = [
73
73
'promoteBuffers' ,
74
74
'promoteLongs' ,
75
75
'bsonRegExp' ,
76
- 'enableUtf8Validation' ,
77
76
'promoteValues' ,
78
77
'compression' ,
79
78
'retryWrites'
Original file line number Diff line number Diff line change @@ -27,8 +27,7 @@ const ILLEGAL_COMMAND_FIELDS = new Set([
27
27
'promoteBuffers' ,
28
28
'bsonRegExp' ,
29
29
'serializeFunctions' ,
30
- 'ignoreUndefined' ,
31
- 'enableUtf8Validation'
30
+ 'ignoreUndefined'
32
31
] ) ;
33
32
34
33
/** @public
Original file line number Diff line number Diff line change @@ -33,7 +33,6 @@ const exclusionList = [
33
33
'bsonRegExp' ,
34
34
'serializeFunctions' ,
35
35
'ignoreUndefined' ,
36
- 'enableUtf8Validation' ,
37
36
'scope' // this option is reformatted thus exclude the original
38
37
] ;
39
38
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ type PermittedBSONOptionKeys =
21
21
| 'promoteValues'
22
22
| 'bsonRegExp'
23
23
| 'fieldsAsRaw'
24
- | 'enableUtf8Validation'
25
24
| 'raw' ;
26
25
27
26
const keys = null as unknown as PermittedBSONOptionKeys ;
You can’t perform that action at this time.
0 commit comments