Make nsIURI::SchemeIs infallible
Categories
(Core :: Networking, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox66 | --- | fixed |
People
(Reporter: qdot, Assigned: qdot)
References
Details
(Whiteboard: [necko-triaged])
Attachments
(1 file)
nsIURI::SchemeIs will only fail on null arguments now. It used to have more error cases, but most of these have been removed. Make SchemeIs infallible to clean up the C++ URI.
Assignee | ||
Comment 1•6 years ago
|
||
This blocks bug 1469429 because I ran into this trying to do some DocShell cleanup.
This should remove the nsContentUtils SchemeIs call that basically does an infallible return, too.
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 2•6 years ago
|
||
There is a massive amount of old-style SchemeIs usage around the codebase, and some of it is rather gross due to awkward compound logic (i.e. https://searchfox.org/mozilla-central/rev/5053031ba7621fa8f63f42de4c204ab3561e4e59/chrome/nsChromeRegistryChrome.cpp#654). Since all these sites required outside variable storage due to XPCOM, it's not simple to do a mass find/replace to clean it up. I'm just landing the IDL definitions in this bug, then will break out cleanup per top/second level directories into other bugs. The current code won't break due to this, so we can do cleanup in stages.
Assignee | ||
Comment 3•6 years ago
|
||
Updated•6 years ago
|
Comment 5•6 years ago
•
|
||
Unfortunately, I don't think the asserts that landed in this bug are OK. The idl says:
boolean schemeIs(in string scheme);
and xpconnect will happily allow JS to pass null for a "string" argument, making it into a nullptr char* on the C++ side. So there's nothing preventing null ending up in there, from the JS side.
A testcase that crashes with these changes is evaluating this in the browser console:
Services.io.newURI("data:text/plain,aaa").schemeIs(null)
It might be OK to just have schemeIs return false when the string arg is null, though, instead of asserting that it's not null.
Comment 6•6 years ago
|
||
bugherder |
Comment 7•6 years ago
|
||
(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #5)
It might be OK to just have schemeIs return false when the string arg is null, though, instead of asserting that it's not null.
Great point. I put up a patch in bug 1519711.
Assignee | ||
Updated•6 years ago
|
Comment 8•5 years ago
|
||
Maybe [infallible]
annotation should be used instead of writing an infallible variant manually.
Description
•