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
- Use a simple lowercase Pornhub language subdomain code: www, cn, jp, fr, de, etc.
- Avoid dots, slashes, spaces, or special characters in the language segment.
- Leave language unset to default to 'www'.
- 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
- Restrict language to bare subdomain codes (www, cn, jp, ...).
- Reject anything with dots, slashes, spaces, or special characters up front.
- Default to 'www' when the segment is absent.
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
- Invalid language
- Invalid category
- At least one valid search parameter is required
- 无法检测 Discuz 版本,请在路由中指定版本参数,如 /discuz/x/ 或 /discuz/7/
- 通知类型${typeParam}未定义
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/86ea1c58585add7e.
Report an issue: GitHub.