DIYgod/RSSHub · warning · InvalidParameterError

Invalid language

Error message

Invalid language

What it means

InvalidParameterError thrown by the Pornhub category_url handler when the language path segment fails isValidHost. The helper validates the segment as a DNS label (alphanumeric/hyphen, per RFC 1031 style) because it is interpolated directly into the subdomain: https://{language}.pornhub.com/... Anything failing that regex is rejected before the request.

Source

Thrown at lib/routes/pornhub/category-url.ts:40

        nsfw: true,
    },
    name: 'Video List',
    maintainers: ['I2IMk', 'queensferryme'],
    handler,
    description: `**\`language\`**

Refer to [Pornhub F.A.Qs](https://help.pornhub.com/hc/en-us/articles/360044327034-How-do-I-change-the-language-), English by default. For example:

- \`cn\` (Chinese), for Pornhub in China <https://cn.pornhub.com>;

- \`jp\` (Japanese), for Pornhub in Japan <https://jp.pornhub.com> etc.`,
};

async function handler(ctx) {
    const { language = 'www', url = 'video', img } = ctx.req.param();
    const link = `https://${language}.pornhub.com/${url}`;
    if (!isValidHost(language)) {
        throw new InvalidParameterError('Invalid language');
    }

    const { data: response } = await got(link, { headers });
    const $ = load(response);
    const showImages = img === 'img=1';
    const items = $('#videoCategory .videoBox')
        .toArray()
        .map((e) => parseItems($(e), showImages));

    return {
        title: $('title').text(),
        link,
        language: $('html').attr('lang') as any,
        item: items,
    };
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Use a simple lowercase Pornhub language subdomain code: www, cn, jp, fr, de, etc.
  2. Avoid dots, slashes, spaces, or special characters in the language segment.
  3. Leave language unset to default to 'www'.
  4. If you need a region, confirm Pornhub actually has a subdomain for it before subscribing.

Example fix

// before: /pornhub/category_url/video/cn.
// after:  /pornhub/category_url/video/cn
Defensive patterns

Strategy: validation

Validate before calling

import { isValidHost } from '@/utils/valid-host';
function isValidLanguageSegment(lang: string): boolean {
  return typeof lang === 'string' && lang.length > 0 && isValidHost(lang);
}
if (!isValidLanguageSegment(language)) {
  // reject before building the pornhub URL
}

Type guard

const isValidLanguageSegment = (lang: unknown): lang is string =>
  typeof lang === 'string' && /^[\dA-Z](?:[\dA-Z-]{0,61}[\dA-Z])?$/i.test(lang);

Try / catch

try {
  // category_url handler
} catch (e) {
  if (e instanceof InvalidParameterError && /Invalid language/.test(e.message)) {
    // surface allowed language subdomain codes
  }
}

Prevention

When it happens

Trigger: Passing a language value with dots, slashes, underscores, spaces, or special characters (e.g. 'en-us', 'www.', 'cn.', ''); passing an unsupported locale code; URL-encoding artifacts.

Common situations: User copies a full locale like 'en-US' (hyphen is allowed actually—wait, hyphen IS allowed, but uppercase locale with trailing characters fails); passes 'www' correctly but adds extra path; passes an empty language; passes a code Pornhub does not have a subdomain for (still passes regex but 404s upstream).

Related errors


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