Skip to content

Commit ae9a836

Browse files
committed
fix
1 parent 0a13b3f commit ae9a836

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

spec/ProtectedFields.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,5 +1821,13 @@ describe('ProtectedFields', function () {
18211821
})
18221822
);
18231823
});
1824+
1825+
it('should handle malformed $or with null element', async function () {
1826+
const query = new Parse.Query(Parse.User);
1827+
query.withJSON({ where: { $or: [null, { username: 'test' }] } });
1828+
// Should not throw TypeError from denyProtectedFields;
1829+
// may fail downstream in validateQuery (pre-existing issue)
1830+
await expectAsync(query.find()).toBeRejected();
1831+
});
18241832
});
18251833
});

src/RestQuery.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,9 @@ _UnsafeRestQuery.prototype.denyProtectedFields = async function () {
848848
this.findOptions
849849
) || [];
850850
const checkWhere = (where) => {
851+
if (typeof where !== 'object' || where === null) {
852+
return;
853+
}
851854
for (const key of protectedFields) {
852855
if (key in where) {
853856
throw createSanitizedError(

0 commit comments

Comments
 (0)