Changeset b1512e0 in Klonkt


Ignore:
Timestamp:
07/28/2026 08:54:20 AM (6 weeks ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
bdb78e4
Parents:
3f32994
Message:

De kop-lezer stopte op een og:image in een script, net voor de echte tag

Op mijn machine werkte YouTube, op de VPS niet. Verschil: die krijgt een andere
variant van de pagina (lang=de-DE), en daarin staat de string og:image eerst in
inline JavaScript. Mijn vroege stop trapte daarin en kapte de pagina af op 661kB,
net voor het echte meta-blok. Resultaat: geen oEmbed-link, geen og-tags, geen
kaart.

Dat is dezelfde near-miss als de body-cap eerder, met een andere oorzaak: ik
stopte met lezen op het moment dat het ER uitzag alsof ik klaar was. De stop
vraagt nu om een echte <meta ...og:image en niet om de kale string.

Changed files:
src/services/EmbedResolver.js

  • vroege stop vereist een meta-tag, geen losse string

src/services/ActivityPubService.js

  • SELFHEAL_VERSION 18 -> 19

test/embed-resolver.test.js

  • regressietest met een lokkertje in een script voor de echte tag

remarks: 215 tests groen.

-robo
Co-Authored-By: Claude Opus 4.8 <noreply@…>

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    r3f32994 rb1512e0  
    28492849// during a flux window, e.g. a fleet-wide update), and drops notes that are gone
    28502850// (404/410). Bump SELFHEAL_VERSION only on a release that warrants a re-sync.
    2851 const SELFHEAL_VERSION = 18; // v18: link previews no longer hang behind the note re-fetch (an unreachable origin skipped the whole row)
     2851const SELFHEAL_VERSION = 19; // v19: head-read no longer stops on an og:image mention inside inline script
    28522852async function fetchNoteAP(url) {
    28532853  try {
  • src/services/EmbedResolver.js

    r3f32994 rb1512e0  
    231231      // the full string every read turns a 1MB page into quadratic work.
    232232      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;
    234238      tail = chunk.slice(-512);
    235239    }
  • test/embed-resolver.test.js

    r3f32994 rb1512e0  
    182182  assert.ok(page && page.includes('og:image'), 'the head survives the cap');
    183183});
     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.
     188test('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.