From aebb8736f988fad68d64700505f5bd90ce00f87a Mon Sep 17 00:00:00 2001 From: Bretton <36870434+BrettM86@users.noreply.github.com> Date: Thu, 16 Jul 2026 03:49:01 -0700 Subject: [PATCH] fix(markdown): stop rewriting mailto links into profile links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Lemmy-era implicit-user-mention rewrite turned every real email link into a dead /profile/ link — e.g. support@coves.social on /legal linked to a nonexistent profile. Coves handles are DNS names, not user@instance pairs, so drop the rewrite; mailto links stay email links. Co-Authored-By: Claude Fable 5 --- src/lib/app/markdown/renderers/plugins.js | 11 +++----- .../app/markdown/renderers/plugins.test.ts | 26 +++++-------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/lib/app/markdown/renderers/plugins.js b/src/lib/app/markdown/renderers/plugins.js index 8a84fd70..8d24d6bb 100644 --- a/src/lib/app/markdown/renderers/plugins.js +++ b/src/lib/app/markdown/renderers/plugins.js @@ -94,7 +94,6 @@ export const linkify = markedLinkifyIt( const regexes = { user: /^https:\/\/([a-zA-Z0-9.-]+)(\/u\/)([a-zA-Z0-9.-_]+)$/i, community: /^https:\/\/([a-zA-Z0-9.-]+)(\/c\/)([a-zA-Z0-9.-_]+)$/i, - implicitUser: /^mailto:([a-z0-9_.-]+)@(([\da-z.-]+)\.([a-z]{2,63}))/i, } export { regexes as CONTENT_REGEXES } @@ -119,13 +118,9 @@ export const localizeLink = (link) => { if (match?.[3].includes('@')) return `/profile/${match?.[3]}` else return `/profile/${match?.[3]}@${match?.[1]}` } - // Support implicit user syntax (no preceding @), by messing with mailto links. - if (regexes.implicitUser.test(link)) { - const exec = regexes.implicitUser.exec(link) - - if (!exec?.[1] || !exec?.[2]) return - return `/profile/${exec[1]}@${exec[2]}` - } + // NOTE: mailto: links are deliberately left untouched. The old Lemmy-era + // "implicit user mention" rewrite turned every real email link (e.g. + // support@coves.social on /legal) into a dead /profile/ link. } export function subSupscriptExtension(tokensExtractor) { diff --git a/src/lib/app/markdown/renderers/plugins.test.ts b/src/lib/app/markdown/renderers/plugins.test.ts index 9e6626b6..ee8375fd 100644 --- a/src/lib/app/markdown/renderers/plugins.test.ts +++ b/src/lib/app/markdown/renderers/plugins.test.ts @@ -28,23 +28,16 @@ describe('localizeLink - user links', () => { }) // --------------------------------------------------------------------------- -// localizeLink() - implicit user links (mailto) +// localizeLink() - mailto links stay untouched (real email links must work) // --------------------------------------------------------------------------- -describe('localizeLink - implicit user links (mailto)', () => { - it('rewrites mailto link to /profile/ path', () => { - const result = localizeLink('mailto:alice@coves.social') - expect(result).toBe('/profile/alice@coves.social') +describe('localizeLink - mailto links', () => { + it('leaves plain mailto links untouched', () => { + expect(localizeLink('mailto:alice@coves.social')).toBeUndefined() }) - it('rewrites mailto link with subdomain instance', () => { - const result = localizeLink('mailto:bob@lemmy.world') - expect(result).toBe('/profile/bob@lemmy.world') - }) - - it('handles username with dots and hyphens', () => { - const result = localizeLink('mailto:first.last@example.org') - expect(result).toBe('/profile/first.last@example.org') + it('leaves mailto links with dots and hyphens untouched', () => { + expect(localizeLink('mailto:first.last@example.org')).toBeUndefined() }) }) @@ -116,11 +109,4 @@ describe('CONTENT_REGEXES', () => { true, ) }) - - it('exports implicitUser regex', () => { - expect(CONTENT_REGEXES.implicitUser).toBeInstanceOf(RegExp) - expect(CONTENT_REGEXES.implicitUser.test('mailto:alice@coves.social')).toBe( - true, - ) - }) }) -- 2.51.2