Changeset 26c5f71 in Klonkt
- Timestamp:
- 08/02/2026 07:23:10 AM (5 weeks ago)
- Branches:
- main
- Children:
- 679924e
- Parents:
- 17546af
- git-author:
- Bart <bart@âĻ> (08/02/2026 07:20:46 AM)
- git-committer:
- Bart <bart@âĻ> (08/02/2026 07:23:10 AM)
- Files:
-
- 1 added
- 1 edited
-
src/routes/activitypub.js (modified) (2 diffs)
-
test/webfinger-bare-host.test.js (added)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/activitypub.js
r17546af r26c5f71 44 44 const publicSite = (slug) => db.prepare('SELECT * FROM sites WHERE slug = ? AND (is_public IS NULL OR is_public = 1)').get(slug); 45 45 const primarySlug = () => { const r = db.prepare('SELECT slug FROM sites WHERE is_primary = 1').get(); return r && r.slug; }; 46 // A hostname as a human types it and as DNS stores it are the same host: 47 // `đŠĩ.is.wildenvrij.nl` IS `xn--zz9h.is.wildenvrij.nl`. WHATWG URL does the IDNA, 48 // so compare the ASCII form and never the bytes the client happened to send. 49 const asciiHost = (h) => { 50 try { return new URL(`https://${h}`).host.toLowerCase(); } catch { return String(h).trim().toLowerCase(); } 51 }; 46 52 47 53 // ââ WebFinger âââââââââââââââââââââââââââââââââââââââââââââââââââââ … … 49 55 const m = String(req.query.resource || '').match(/^acct:([^@]+)@(.+)$/i); 50 56 if (!m) return res.status(400).type('text/plain').send('bad resource'); 51 const site = publicSite(m[1]); 57 const user = m[1]; 58 let site = publicSite(user); 59 // `acct:<host>@<host>` asks for this server's primary actor â the convention 60 // Shaer's Handle relies on so a Ward is reachable without knowing anyone's 61 // slug. Typing `đŠĩ.is.wildenvrij.nl`, pasting `https://đŠĩ.is.wildenvrij.nl` 62 // (which the client's URL parser silently punycodes) and sending the xn-- 63 // form by hand are three spellings of one address; all arrive here with the 64 // host sitting in the user position, and all must find the same actor. 65 if (!site && asciiHost(user) === asciiHost(hostOf(req))) { 66 const slug = primarySlug(); 67 if (slug) site = publicSite(slug); 68 } 52 69 if (!site) return res.status(404).end(); 53 70 res.type('application/jrd+json; charset=utf-8');
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)