Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: tools.checkRangeQuery does not consider edge case of update.messages.length === 0 #698

Closed
titanism opened this issue Jun 24, 2024 · 1 comment

Comments

@titanism
Copy link
Contributor

titanism commented Jun 24, 2024

As you can see from code snippet below , if the case is that update.messages.length is 0, then an invalid query object will be returned. This namely happens for queryAll cases (e.g. 1:*) for COPY.

let cursor = await db.database
.collection('messages')
.find({
mailbox: mailboxData._id,
uid: tools.checkRangeQuery(update.messages)
}) // no projection as we need to copy the entire message
.sort({ uid: 1 })
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES);

> const tools = require('wildduck/lib/tools')
undefined
> tools.checkRangeQuery([], false)
{ '$gte': undefined, '$lte': undefined }
> tools.checkRangeQuery([], true)
{ '$not': { '$gte': undefined, '$lte': undefined } }
@titanism titanism changed the title Bug: tools.checkRangeQuery does not consider edge case of uids.length === 0 Bug: tools.checkRangeQuery does not consider edge case of update.messages.length === 0 Jun 24, 2024
@titanism
Copy link
Contributor Author

The fix may also be needed here

uid: options.messageQuery ? options.messageQuery : tools.checkRangeQuery(options.messages)

@titanism titanism reopened this Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant