DIYgod/RSSHub · warning · InvalidParameterError

Invalid domain

Error message

Invalid domain

What it means

InvalidParameterError thrown when the `domain` path param of /bt0/tlist/:domain/:sc does not match /^[1-9]$/. Identical guard to bt0/mv: the single digit selects the mirror host www.{domain}bt0.com and prevents SSRF/host injection.

Source

Thrown at lib/routes/bt0/tlist.ts:42

        supportBT: true,
        supportPodcast: false,
        supportScihub: false,
    },
    radar: [
        {
            source: ['2bt0.com/tlist/'],
        },
    ],
    name: '最新资源列表',
    maintainers: ['miemieYaho'],
    handler,
};

async function handler(ctx) {
    const domain = ctx.req.param('domain') ?? '2';
    const sc = ctx.req.param('sc');
    if (!/^[1-9]$/.test(domain)) {
        throw new InvalidParameterError('Invalid domain');
    }
    if (!/^[1-5]$/.test(sc)) {
        throw new InvalidParameterError('Invalid sc');
    }

    const host = `https://www.${domain}bt0.com`;
    const _link = `${host}/prod/core/system/getTList?sc=${sc}`;

    const data = await doGot(0, host, _link);
    const items = data.data.list.map((item) => ({
        title: item.zname,
        guid: item.zname,
        description: `《${item.title}》  导演: ${item.daoyan}<br>编剧: ${item.bianji}<br>演员: ${item.yanyuan}<br>简介: ${item.conta.trim()}`,
        link: host + item.aurl,
        pubDate: item.eztime.endsWith('前') ? parseRelativeDate(item.eztime) : item.eztime,
        enclosure_type: 'application/x-bittorrent',
        enclosure_url: item.zlink,
        enclosure_length: genSize(item.zsize),

View on GitHub (pinned to bed535e087)

Solutions

  1. Use a single digit 1-9 for domain, e.g. /bt0/tlist/2/1.
  2. Omit domain to default to '2'.
  3. Verify the route URL has no stray characters in the domain segment.

Example fix

// before
if (!/^[1-9]$/.test(domain)) {
    throw new InvalidParameterError('Invalid domain');
}
// after
if (!/^[1-9]$/.test(domain)) {
    throw new InvalidParameterError(`Invalid domain '${domain}': expected a single digit 1-9`);
}
Defensive patterns

Strategy: validation

Validate before calling

if (!/^[1-9]$/.test(domain)) {
    throw new InvalidParameterError(`Invalid domain '${domain}': expected a single digit 1-9`);
}

Type guard

const isBt0Domain = (d: string): boolean => /^[1-9]$/.test(d);

Prevention

When it happens

Trigger: A request to /bt0/tlist/:domain/:sc with a domain value outside '1'..'9' (two digits, '0', letters, etc.). The default '2' is valid, so this only fires on an explicitly bad supplied value.

Common situations: Passing the full hostname; passing a multi-digit mirror id; URL encoding issues.

Related errors


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