Changeset b1512e0 in Klonkt
- Timestamp:
- 07/28/2026 08:54:20 AM (6 weeks ago)
- Branches:
- main
- Children:
- bdb78e4
- Parents:
- 3f32994
- Files:
-
- 3 edited
-
src/services/ActivityPubService.js (modified) (1 diff)
-
src/services/EmbedResolver.js (modified) (1 diff)
-
test/embed-resolver.test.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
r3f32994 rb1512e0 2849 2849 // during a flux window, e.g. a fleet-wide update), and drops notes that are gone 2850 2850 // (404/410). Bump SELFHEAL_VERSION only on a release that warrants a re-sync. 2851 const SELFHEAL_VERSION = 1 8; // v18: link previews no longer hang behind the note re-fetch (an unreachable origin skipped the whole row)2851 const SELFHEAL_VERSION = 19; // v19: head-read no longer stops on an og:image mention inside inline script 2852 2852 async function fetchNoteAP(url) { 2853 2853 try { -
src/services/EmbedResolver.js
r3f32994 rb1512e0 231 231 // the full string every read turns a 1MB page into quadratic work. 232 232 const window = tail + chunk; 233 if (len >= MAX_HEAD || /<\/head>/i.test(window) || /og:image/i.test(window)) done_ = true; 233 // Stop on the real <meta property="og:image">, not on the bare string. 234 // Big sites carry "og:image" inside inline JSON long before the actual 235 // tag, and stopping there cut the page off just short of the meta block: 236 // the same near-miss as the old size cap, with a different cause. 237 if (len >= MAX_HEAD || /<\/head>/i.test(window) || /<meta[^>]{0,300}og:image/i.test(window)) done_ = true; 234 238 tail = chunk.slice(-512); 235 239 } -
test/embed-resolver.test.js
r3f32994 rb1512e0 182 182 assert.ok(page && page.includes('og:image'), 'the head survives the cap'); 183 183 }); 184 185 // Regression: big sites carry the bare string "og:image" inside inline JSON long 186 // before the real meta tag. Stopping the read there cut the page off just short 187 // of the tags and produced no card at all. 188 test('the head read does not stop on an og:image mention inside a script', async () => { 189 const { liveIO } = await import('../src/services/EmbedResolver.js'); 190 const page = '<html><head><script>var cfg={"og:image":"decoy"};</script>' 191 + 'y'.repeat(3000) 192 + '<meta property="og:title" content="Echt"><meta property="og:image" content="https://x/real.png">' 193 + '</head></html>'; 194 const fakeFetch = async () => ({ ok: true, headers: { get: () => '999' }, text: async () => page }); 195 const io = liveIO({ safeFetch: fakeFetch, detectProvider: () => null }); 196 const got = await io.getPage('https://x/p'); 197 const { findOpenGraph } = await import('../src/services/EmbedResolver.js'); 198 assert.equal(findOpenGraph(got).image, 'https://x/real.png', 'reads past the decoy to the real tag'); 199 });
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)