Closed Bug 2066620 Opened 2 months ago Closed 1 month ago

publicSuffix.isKnownSuffix does not throw for inputs that are invalid host names

Categories

(WebExtensions :: General, defect, P3)

defect

Tracking

(firefox158 fixed)

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: robwu, Assigned: kzar)

References

Details

(Keywords: dev-doc-complete, Whiteboard: [addons-jira])

Attachments

(1 external file)

The implementation at https://searchfox.org/firefox-main/rev/600bd2128b2ba435b9698ec8b61394aa27c7c93f/toolkit/components/extensions/child/ext-publicSuffix.js#39-45 catches and swallows errors unconditionally.

Dave noted at https://bugzilla.mozilla.org/show_bug.cgi?id=1315558#c42 that this behavior is not in line with the original API proposal, the MDN documentation and Chromium's implementation:

I'm working on the Chromium implementation of this API at the moment, and I noticed a (very minor) bug in the Firefox implementation. For a case like browser.publicSuffix.isKnownSuffix("invalid%.domain"), the API is returning false instead of throwing an exception. That seems to contradict the API proposal and the docs in MDN (and soon to be the Chromium implementation).

When I approved the implementation, I reasoned that returning false for an invalid host name is reasonable. But given that the MDN documentation, original API proposal and Chromium's implementation all expect a thrown error, and throwing would just be more consistent across all other publicSuffix methods, I'm supportive of changing the behavior to just throw.

Assignee: nobody → kzar
Whiteboard: [addons-jira]

The browser.publicSuffix.isKnownSuffix extension API should throw when the
given hostname is invalid, instead of returning false.

See https://github.com/w3c/webextensions/blob/main/proposals/public-suffix.md#4-invalid-hostname

Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED

https://hg-edge.mozilla.org/mozilla-central/rev/83fbfef2e78c

(I think I confused the automation by closing this before the mozilla-central commit was merged, sorry.)

Target Milestone: --- → 158 Branch

The docs for this API already specify that it should throw for invalid hostnames, but it could be worth mentioning the fix in the release notes for add-ons devs.

Keywords: dev-doc-needed
See Also: → 2077286
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: