DIYgod/RSSHub · warning

Invalid country

Error message

Invalid country

What it means

Thrown by the fashionnetwork news route when the `country` path parameter (default 'ww') fails isValidHost, after sectors/categories are normalized. The value feeds `https://${country}.fashionnetwork.com`, so only a single safe DNS label is accepted.

Source

Thrown at lib/routes-deprecated/fashionnetwork/news.js:17

const got = require('@/utils/got');
const cheerio = require('cheerio');
const { isValidHost } = require('@/utils/valid-host');

module.exports = async (ctx) => {
    const country = ctx.params.country || 'ww';
    let sectors = ctx.params.sectors || '';
    let categories = ctx.params.categories || '';

    sectors = sectors === 'all' ? '' : sectors;
    categories = categories === 'all' ? '' : categories;

    const sectorsUrl = sectors ? 'sectors%5B%5D=' + sectors.split(',').join('&sectors%5B%5D=') : '';
    const categoriesUrl = categories ? 'categs%5B%5D=' + categories.split(',').join('&categs%5B%5D=') : '';

    if (!isValidHost(country)) {
        throw new Error('Invalid country');
    }

    const rootUrl = `https://${country}.fashionnetwork.com`;
    const currentUrl = `${rootUrl}/news/s.jsonp?${sectorsUrl}&${categoriesUrl}`;
    const response = await got({
        method: 'get',
        url: currentUrl,
    });

    const $ = cheerio.load(
        unescape(response.data.match(/"html":"(.*)","relatedUrl"/)[1].replaceAll(/\\(u[\dA-Fa-f]{4})/gm, '%$1'))
            .replaceAll('\\n', '')
            .replaceAll('\\/', '/')
    );

    const list = $('.list-ui__title')
        .slice(0, 10)
        .map((_, item) => {

View on GitHub (pinned to bed535e087)

Solutions

  1. Use a valid country label (e.g. 'ww', 'fr', 'cn').
  2. Omit the segment to default to 'ww'.
  3. Keep sectors/categories values to comma-separated slugs only.

Example fix

// before
/fashionnetwork/news/fr/news
// after
/fashionnetwork/news/fr
Defensive patterns

Strategy: validation

Validate before calling

import { isValidHost } from '@/utils/valid-host';
const country = params.country ?? 'ww';
if (!isValidHost(country)) throw new Error('Invalid country');

Type guard

const isSafeCountry = (v: unknown): boolean =>
  typeof v === 'string' && /^[a-z0-9-]+$/i.test(v) && !v.includes('.');

Prevention

When it happens

Trigger: Request to /fashionnetwork/news/:country with a country containing invalid host characters (dots, slashes, protocol).

Common situations: Typo; passing the full hostname; traversal attempt; copy-pasting a URL fragment into the path.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/ed04840fc1b2873f. Report an issue: GitHub.