Foundry376/Mailspring · error

Invalid URL

Error message

Invalid URL

What it means

Validation guard in performWebUnsubscribe: the URL passed for one-click/browser unsubscribe failed the /^https?/ check, so opening it in the user's default browser is refused. Protects against arbitrary schemes (e.g. 'ftp:', 'javascript:') smuggled in via a List-Unsubscribe header.

Source

Thrown at app/internal_packages/list-unsubscribe/lib/unsubscribe-service.ts:157

    throw new Error('Invalid mailto URI');
  }

  // Use the application's openUrl handler which routes to DraftStore._onHandleMailtoLink
  // This creates a draft and opens it in the composer for user review
  const sanitizedUri = encodeURI(decodeURI(mailtoUri));
  require('@electron/remote').getGlobal('application').openUrl(sanitizedUri);
}

/**
 * Opens the unsubscribe URL in the user's default browser.
 *
 * This is used as a fallback when one-click is not available.
 *
 * @param url - The HTTP/HTTPS URL to open
 */
export function performWebUnsubscribe(url: string): void {
  if (!/^https?:\/\/.+/i.test(url)) {
    throw new Error('Invalid URL');
  }
  shell.openExternal(url);
}

/**
 * Determines the best unsubscribe method based on available options.
 *
 * Priority order:
 * 1. One-click HTTPS (if List-Unsubscribe-Post header present) - instant, no user interaction
 * 2. Mailto - opens composer for user review
 * 3. Regular HTTPS/HTTP - opens in browser
 *
 * @param options - Parsed unsubscribe options from the header
 * @param hasOneClickSupport - Whether List-Unsubscribe-Post header indicates one-click support
 * @returns The best unsubscribe option, or null if none available
 */
export function getBestUnsubscribeOption(
  options: UnsubscribeOption[],

View on GitHub (pinned to 648c685d60)

Solutions

  1. Parse the URL and require protocol http: or https: explicitly rather than a prefix regex
  2. Show a warning to the user when the unsubscribe link in the header is unusable
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at app/internal_packages/list-unsubscribe/lib/unsubscribe-service.ts:157 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Foundry376/Mailspring@648c685d60 (2026-09-03). Data as JSON: /api/errors/7acae9a302056e76. Report an issue: GitHub.