DIYgod/RSSHub · warning

Invalid language code

Error message

Invalid language code

What it means

Thrown by the bandisoft route when the `lang` path parameter (default 'en') fails isValidHost. isValidHost rejects values that are not valid DNS-label-safe (no dots, no slashes, no protocol, ASCII-only, etc.), preventing injection into the constructed URL `https://${lang}.bandisoft.com`.

Source

Thrown at lib/routes-deprecated/bandisoft/index.js:9

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

module.exports = async (ctx) => {
    const lang = ctx.params.lang || 'en';
    const id = ctx.params.id || 'bandizip';
    if (!isValidHost(lang)) {
        throw new Error('Invalid language code');
    }

    const rootUrl = `https://${lang}.bandisoft.com`;
    const currentUrl = `${rootUrl}/${id}/history/`;
    const response = await got({
        method: 'get',
        url: currentUrl,
    });

    const $ = cheerio.load(response.data);

    const items = $('h2')
        .map((_, item) => {
            item = $(item);

            const title = item.text();
            item.children('font').remove();

View on GitHub (pinned to bed535e087)

Solutions

  1. Use a plain subdomain label supported by bandisoft (e.g. 'en', 'zh', 'ja', 'ko').
  2. Omit the lang segment to fall back to the default 'en'.
  3. Avoid embedding dots, slashes, or protocols in the path parameter.

Example fix

// before
/bandisoft/en-US/bandizip
// after
/bandisoft/en/bandizip
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

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

Prevention

When it happens

Trigger: User requests /bandisoft/<lang>/... with a lang containing dots, slashes, protocol characters, or otherwise invalid host characters.

Common situations: Typo such as 'en-US' (contains a dash is usually fine but a dot/slash is not); attempting path traversal; passing a full URL fragment.

Related errors


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