@@ -141,7 +141,7 @@ const valueAsDate = value => {
141
141
return false ;
142
142
}
143
143
144
- function transformQueryKeyValue ( className , key , value , { validate } = { } , schema ) {
144
+ function transformQueryKeyValue ( className , key , value , schema ) {
145
145
switch ( key ) {
146
146
case 'createdAt' :
147
147
if ( valueAsDate ( value ) ) {
@@ -184,9 +184,6 @@ function transformQueryKeyValue(className, key, value, { validate } = {}, schema
184
184
// Special-case auth data.
185
185
return { key : `_auth_data_${ provider } .id` , value} ;
186
186
}
187
- if ( validate && ! key . match ( / ^ [ a - z A - Z ] [ a - z A - Z 0 - 9 _ \. ] * $ / ) ) {
188
- throw new Parse . Error ( Parse . Error . INVALID_KEY_NAME , 'invalid key name: ' + key ) ;
189
- }
190
187
}
191
188
192
189
const expectedTypeIsArray =
@@ -224,13 +221,17 @@ function transformQueryKeyValue(className, key, value, { validate } = {}, schema
224
221
// restWhere is the "where" clause in REST API form.
225
222
// Returns the mongo form of the query.
226
223
// Throws a Parse.Error if the input query is invalid.
224
+ const specialQuerykeys = [ '$and' , '$or' , '_rperm' , '_wperm' , '_perishable_token' , '_email_verify_token' ] ;
227
225
function transformWhere ( className , restWhere , { validate = true } = { } , schema ) {
228
226
let mongoWhere = { } ;
229
227
if ( restWhere [ 'ACL' ] ) {
230
228
throw new Parse . Error ( Parse . Error . INVALID_QUERY , 'Cannot query on ACL.' ) ;
231
229
}
232
230
for ( let restKey in restWhere ) {
233
- let out = transformQueryKeyValue ( className , restKey , restWhere [ restKey ] , { validate } , schema ) ;
231
+ if ( validate && ! specialQuerykeys . includes ( restKey ) && ! restKey . match ( / ^ [ a - z A - Z ] [ a - z A - Z 0 - 9 _ \. ] * $ / ) ) {
232
+ throw new Parse . Error ( Parse . Error . INVALID_KEY_NAME , `Invalid key name: ${ restKey } ` ) ;
233
+ }
234
+ let out = transformQueryKeyValue ( className , restKey , restWhere [ restKey ] , schema ) ;
234
235
mongoWhere [ out . key ] = out . value ;
235
236
}
236
237
return mongoWhere ;
0 commit comments