Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ To be released.
[#849]: https://github.com/fedify-dev/fedify/issues/849
[#851]: https://github.com/fedify-dev/fedify/pull/851

### @fedify/cli

- Fixed `fedify nodeinfo` choosing SVG favicons whose filenames use
uppercase `.SVG` extensions or include query strings or fragments. The
command now ignores those SVG favicon links and falls back to
`/favicon.ico` before rendering terminal art. [[#891], [#918] by Junghoon
Ban]

[#891]: https://github.com/fedify-dev/fedify/issues/891
[#918]: https://github.com/fedify-dev/fedify/pull/918

### @fedify/vocab

- Fixed Activity Vocabulary parsing so malformed language tags in remote
Expand Down
50 changes: 50 additions & 0 deletions packages/cli/src/nodeinfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,56 @@ test("getFaviconUrl - svg icons only falls back to /favicon.ico", async () => {
fetchMock.hardReset();
});

const HTML_WITH_UPPERCASE_SVG_ONLY = `
<!DOCTYPE html>
<html>
<head>
<title>Test Site</title>
<link rel="icon" href="/icon.SVG" type="image/svg+xml">
</head>
<body>Test</body>
</html>
`;

test("getFaviconUrl - uppercase svg icons only falls back to /favicon.ico", async () => {
fetchMock.spyGlobal();

fetchMock.get("https://example.com/", {
body: HTML_WITH_UPPERCASE_SVG_ONLY,
headers: { "Content-Type": "text/html" },
});

const result = await getFaviconUrl("https://example.com/");
assert.equal(result.href, "https://example.com/favicon.ico");

fetchMock.hardReset();
});

const HTML_WITH_UPPERCASE_SVG_WITH_QUERY = `
<!DOCTYPE html>
<html>
<head>
<title>Test Site</title>
<link rel="icon" href="/icon.SVG?v=1#icon" type="image/svg+xml">
</head>
<body>Test</body>
</html>
`;

test("getFaviconUrl - uppercase svg icons with query and hash fall back to /favicon.ico", async () => {
fetchMock.spyGlobal();

fetchMock.get("https://example.com/", {
body: HTML_WITH_UPPERCASE_SVG_WITH_QUERY,
headers: { "Content-Type": "text/html" },
});

const result = await getFaviconUrl("https://example.com/");
assert.equal(result.href, "https://example.com/favicon.ico");

fetchMock.hardReset();
});

const HTML_WITHOUT_ICON = `
<!DOCTYPE html>
<html>
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/src/nodeinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,9 @@ export async function getFaviconUrl(
if (w < 38 || h < 19) continue;
}
if ("href" in attrs) {
if (attrs.href.endsWith(".svg")) continue;
return new URL(attrs.href, response.url);
const parsedUrl = new URL(attrs.href, response.url);
if (parsedUrl.pathname.toLowerCase().endsWith(".svg")) continue;
return parsedUrl;
}
Comment thread
junghoon-vans marked this conversation as resolved.
}
return new URL("/favicon.ico", response.url);
Expand Down
Loading