fix: a listed site ending in a dot gets the phishing warning (closes #534)
The blocklist check hashed the hostname as the page gave it, so "myetheywallet.com." and every subdomain written that way hashed differently from the listed "myetheywallet.com" and opened approval prompts with no warning. The browser and DNS treat both spellings as one host. hostnameVariants() now drops one trailing dot before building the hostname and its parent domains, so the check sees the name the list holds. Model: opus-5-5
This commit was merged in pull request #546.
This commit is contained in:
@@ -110,11 +110,14 @@ function hashListed(hash) {
|
||||
* Generate hostname variants for subdomain matching.
|
||||
* "sub.evil.com" yields ["sub.evil.com", "evil.com"].
|
||||
*
|
||||
* A trailing dot is dropped: "evil.com." is the fully qualified spelling of
|
||||
* "evil.com", and the browser loads the same site from either.
|
||||
*
|
||||
* @param {string} hostname
|
||||
* @returns {string[]}
|
||||
*/
|
||||
function hostnameVariants(hostname) {
|
||||
const h = hostname.toLowerCase();
|
||||
const h = hostname.toLowerCase().replace(/\.$/, "");
|
||||
const variants = [h];
|
||||
const parts = h.split(".");
|
||||
// Parent domains: a.b.c.d -> b.c.d, c.d
|
||||
|
||||
Reference in New Issue
Block a user