Closed Bug 1679464 Opened 3 years ago Closed 3 years ago

nsAbQueryStringToExpression::ParseExpression fails when given a ? at the start of the query

Categories

(Thunderbird :: Address Book, defect)

defect

Tracking

(thunderbird_esr78+ fixed)

RESOLVED FIXED
85 Branch
Tracking Status
thunderbird_esr78 + fixed

People

(Reporter: standard8, Assigned: standard8)

References

Details

Attachments

(2 files)

In browser.contacts.quickSearch we are formulating a query string:

https://searchfox.org/comm-central/rev/f6b563aaf622ff6fe9836cd8e6ffe9b2851a63b6/mail/components/extensions/parent/ext-addressBook.js#566-569

Unfortunately generateQueryURI adds a question mark to the beginning of the string. For the JavaScript based address books, this is fine, but it breaks the address books that use compiled code as nsAbQueryStringToExpression::ParseExpression isn't accepting it.

I think the simplest way around this if for ParseExpression to accept the ? like the JavaScript implementation does:

https://searchfox.org/comm-central/rev/f6b563aaf622ff6fe9836cd8e6ffe9b2851a63b6/mailnews/addrbook/modules/AddrBookDirectory.jsm#500-502

The bug is actually even earlier than that: The first character of an LDAP query string must always be a (, so a leading ? is always erroneous. Whatever generates the ? should be fixed, too.

But you're right with your patch - the code should be tolerant. (Internet protocol principle: Conservative in sending, tolerant in receiving.)

Attachment #9189887 - Flags: review+

Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/comm-central/rev/5c8ea2dad760
Extend nsAbQueryStringToExpression::ParseExpression to handle '?' at the start of queries. r=darktrojan

Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED

I double-checked and all of the consumers of generateQueryURI subsequently remove the leading ? from the resulting string at some point, making it pointless to prepend it in the first place, so we could just remove it. (I also removed URI from the name, as we're not using the string as part of a URI any more.)

Attachment #9190265 - Flags: feedback?(standard8)

Thanks, Mark, for the patch and for landing it.

REOPENing (it was closed automatically by the bot), because the root cause isn't fixed yet.

Status: RESOLVED → REOPENED
Resolution: FIXED → ---

Comment on attachment 9190265 [details] [diff] [review]
Alternative approach

I'm fine with taking an alternate approach assuming everything still works. The patch will probably want to revert the C++ changes as well.

Though I did think we generally handled follow-ups in separate bugs...

Attachment #9190265 - Flags: feedback?(standard8)
Assignee: standard8 → nobody

Re-marking as fixed, as this did fix an issue, even if it is not the best for the root cause. I also want to uplift just the simple patch, so for tracking purposes, any follow-ups should be on separate bugs to save confusion.

Assignee: nobody → standard8
Status: REOPENED → RESOLVED
Closed: 3 years ago3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 85 Branch

Comment on attachment 9189887 [details]
Bug 1679464 - Extend nsAbQueryStringToExpression::ParseExpression to handle '?' at the start of queries. r?darktrojan!

[Approval Request Comment]
Regression caused by (bug #): N/A
User impact if declined: If the user has current versions of Exquilla installed (78.0.5) the WebExtension Contacts API will be broken for quick searches - and hence it can break other add-ons.
Testing completed (on c-c, etc.): Landed on c-c.
Risk to taking this patch (and alternatives if risky): Low, simple fix that makes nsAbQueryStringToExpression::ParseExpression handle an extra edge case.

Attachment #9189887 - Flags: approval-comm-esr68?
Attachment #9189887 - Flags: approval-comm-beta?

Comment on attachment 9189887 [details]
Bug 1679464 - Extend nsAbQueryStringToExpression::ParseExpression to handle '?' at the start of queries. r?darktrojan!

I think you meant 78.

Attachment #9189887 - Flags: approval-comm-esr68? → approval-comm-esr78?

Comment on attachment 9189887 [details]
Bug 1679464 - Extend nsAbQueryStringToExpression::ParseExpression to handle '?' at the start of queries. r?darktrojan!

[Triage Comment]
Approved for beta

Attachment #9189887 - Flags: approval-comm-beta? → approval-comm-beta+

Comment on attachment 9189887 [details]
Bug 1679464 - Extend nsAbQueryStringToExpression::ParseExpression to handle '?' at the start of queries. r?darktrojan!

[Triage Comment]
Approved for esr78

Attachment #9189887 - Flags: approval-comm-esr78? → approval-comm-esr78+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: