Closed Bug 1899673 Opened 1 year ago Closed 1 year ago

Port bug 1873973: nsStandardURL incorrectly escapes ^ in the path

Categories

(Thunderbird :: Upstream Synchronization, defect)

Thunderbird 128
defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: darktrojan, Unassigned)

References

Details

Attachments

(2 obsolete files)

No description provided.
Keywords: leave-open
Target Milestone: --- → 128 Branch
Pushed by geoff@darktrojan.net: https://hg.mozilla.org/comm-central/rev/d9ee919f3545 part 1 - Port bug 1873973: nsStandardURL incorrectly escapes ^ in the path. r=aleca

If we run this code to display a message and the URL contains a ^, somehow we end up at the external protocol service trying to save something. That's what this error in the logs is all about. My guess is that somewhere in our code we're not expecting an unescaped ^ and returning an error value to the docShell which decides not to load the URL and throws it to the external helper app service. There's nsImapUrl::EscapeSlashes and UnescapeSlashes which mess about with the caret character, but I've not been successful in changing them to get a working state so far.

If we escape the ^ to %5E before passing it to the docShell, the message loads as intended. But we then end up making a second request to fetch the message from the server, which marks the message as read and fails the test. (I think it's a coincidence that the failing test is browser_markAsRead.js, but it is very handy.)

What does work is replacing kOnlineHierarchySeparatorUnknown with a different character, but I'm unsure if there are any other side-effects that would make it a bad idea.

Does replacing the ^ character in escape and unescape slashes with another character that is not allowed in the path work?
Such as { ?

That's a good idea but no, it doesn't change anything. I don't think those two functions are called near the problem either.

What's weird is that after the error is logged, the rest of the request continues. If the IMAP code had returned an error I don't think that would happen. But I could be wrong about that.

I just closed everything for the day and found 80-something .html.part files on my desktop! I guess the external app helper is at least successful in downloading the request. Also, I've just realised that I've said external protocol service a few times instead of external app service.

(In reply to Geoff Lankow (:darktrojan) from comment #5)

That's a good idea but no, it doesn't change anything. I don't think those two functions are called near the problem either.

What's weird is that after the error is logged, the rest of the request continues. If the IMAP code had returned an error I don't think that would happen. But I could be wrong about that.

Unfortunately I don't know enough about IMAP to figure out what could be wrong.
What I expect is happening is that unescapeSlashes should be called somewhere, but it isn't. That leaves ^ characters in the path - and they used to get escaped by the URL parser, but now they don't.

(In reply to Geoff Lankow (:darktrojan) from comment #3)

What does work is replacing kOnlineHierarchySeparatorUnknown with a different character, but I'm unsure if there are any other side-effects that would make it a bad idea.

Or maybe the kOnlineHierarchySeparatorUnknown should be the same as the character we use to replace /?

See Also: → 1899753

Yes. imap, mailbox, and news schemes use the everything before the query as the origin. Each mail message is a distinct trust domain, so we use the whole spec for comparison.

I'm just coming to the conclusion that the way to fix this is to add an #if IS_ORIGIN_IS_FULL_SPEC_DEFINED block, then check the scheme and return appropriately. Unless we can return earlier where we have an nsIURI available and can check the scheme there.

Come to think of it, don't all file URIs have distinct origins? Can we leverage how that works somehow?

See Also: → 1608318
Duplicate of this bug: 1900153
Duplicate of this bug: 1900154
Attachment #9404707 - Attachment is obsolete: true
Attachment #9404967 - Attachment is obsolete: true
Assignee: geoff → nobody
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Keywords: leave-open
Resolution: --- → WONTFIX
Whiteboard: [stockwell disable-recommended]
Target Milestone: 128 Branch → ---
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: