Skip to content

Commit ac4f177

Browse files
committed
Merge tag '1.3.2'
Fedify 1.3.2
2 parents dae4d16 + 4e5f831 commit ac4f177

File tree

3 files changed

+82
-1
lines changed

3 files changed

+82
-1
lines changed

CHANGES.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ To be released.
2020
[#195]: https://github.com/dahlia/fedify/issues/195
2121

2222

23+
Version 1.3.2
24+
-------------
25+
26+
Released on December 18, 2024.
27+
28+
- Fixed the default document loader to handle the `Link` header with
29+
incorrect syntax. [[#196]]
30+
31+
2332
Version 1.3.1
2433
-------------
2534

@@ -146,6 +155,15 @@ Released on November 30, 2024.
146155
[#193]: https://github.com/dahlia/fedify/issues/193
147156

148157

158+
Version 1.2.10
159+
--------------
160+
161+
Released on December 18, 2024.
162+
163+
- Fixed the default document loader to handle the `Link` header with
164+
incorrect syntax. [[#196]]
165+
166+
149167
Version 1.2.9
150168
-------------
151169

@@ -361,6 +379,15 @@ Released on October 31, 2024.
361379
[#118]: https://github.com/dahlia/fedify/issues/118
362380

363381

382+
Version 1.1.10
383+
--------------
384+
385+
Released on December 18, 2024.
386+
387+
- Fixed the default document loader to handle the `Link` header with
388+
incorrect syntax. [[#196]]
389+
390+
364391
Version 1.1.9
365392
-------------
366393

@@ -617,6 +644,17 @@ Released on October 20, 2024.
617644
[#150]: https://github.com/dahlia/fedify/issues/150
618645

619646

647+
Version 1.0.13
648+
--------------
649+
650+
Released on December 18, 2024.
651+
652+
- Fixed the default document loader to handle the `Link` header with
653+
incorrect syntax. [[#196]]
654+
655+
[#196]: https://github.com/dahlia/fedify/issues/196
656+
657+
620658
Version 1.0.12
621659
--------------
622660

src/runtime/docloader.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,24 @@ test("getDocumentLoader()", async (t) => {
101101
},
102102
));
103103

104+
mf.mock("GET@/obj-w-wrong-link", (_req) =>
105+
new Response(
106+
JSON.stringify({
107+
"@context": "https://www.w3.org/ns/activitystreams",
108+
id: "https://example.com/obj-w-wrong-link",
109+
name: "Fetched object",
110+
type: "Object",
111+
}),
112+
{
113+
status: 200,
114+
headers: {
115+
"Content-Type": "text/html; charset=utf-8",
116+
Link: '<https://example.com/object>; rel="alternate"; ' +
117+
'type="application/ld+json; profile="https://www.w3.org/ns/activitystreams""',
118+
},
119+
},
120+
));
121+
104122
await t.step("Link header", async () => {
105123
assertEquals(await fetchDocumentLoader("https://example.com/link-ctx"), {
106124
contextUrl: "https://www.w3.org/ns/activitystreams",
@@ -150,6 +168,22 @@ test("getDocumentLoader()", async (t) => {
150168
);
151169
});
152170

171+
await t.step("wrong Link header syntax", async () => {
172+
assertEquals(
173+
await fetchDocumentLoader("https://example.com/obj-w-wrong-link"),
174+
{
175+
contextUrl: null,
176+
documentUrl: "https://example.com/obj-w-wrong-link",
177+
document: {
178+
"@context": "https://www.w3.org/ns/activitystreams",
179+
id: "https://example.com/obj-w-wrong-link",
180+
name: "Fetched object",
181+
type: "Object",
182+
},
183+
},
184+
);
185+
});
186+
153187
mf.mock("GET@/html-link", (_req) =>
154188
new Response(
155189
`<html>

src/runtime/docloader.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,16 @@ async function getRemoteDocument(
133133
const linkHeader = response.headers.get("Link");
134134
let contextUrl: string | null = null;
135135
if (linkHeader != null) {
136-
const link = new HTTPHeaderLink(linkHeader);
136+
let link: HTTPHeaderLink;
137+
try {
138+
link = new HTTPHeaderLink(linkHeader);
139+
} catch (e) {
140+
if (e instanceof SyntaxError) {
141+
link = new HTTPHeaderLink();
142+
} else {
143+
throw e;
144+
}
145+
}
137146
if (jsonLd) {
138147
const entries = link.getByRel("http://www.w3.org/ns/json-ld#context");
139148
for (const [uri, params] of entries) {

0 commit comments

Comments
 (0)