{"record":{"id":"86ea1c58585add7e","repo":"DIYgod/RSSHub","slug":"invalid-language","errorCode":null,"errorMessage":"Invalid language","messagePattern":"Invalid language","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":503,"severity":"warning","filePath":"lib/routes/pornhub/category-url.ts","lineNumber":40,"sourceCode":"        nsfw: true,\n    },\n    name: 'Video List',\n    maintainers: ['I2IMk', 'queensferryme'],\n    handler,\n    description: `**\\`language\\`**\n\nRefer 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:\n\n- \\`cn\\` (Chinese), for Pornhub in China <https://cn.pornhub.com>；\n\n- \\`jp\\` (Japanese), for Pornhub in Japan <https://jp.pornhub.com> etc.`,\n};\n\nasync function handler(ctx) {\n    const { language = 'www', url = 'video', img } = ctx.req.param();\n    const link = `https://${language}.pornhub.com/${url}`;\n    if (!isValidHost(language)) {\n        throw new InvalidParameterError('Invalid language');\n    }\n\n    const { data: response } = await got(link, { headers });\n    const $ = load(response);\n    const showImages = img === 'img=1';\n    const items = $('#videoCategory .videoBox')\n        .toArray()\n        .map((e) => parseItems($(e), showImages));\n\n    return {\n        title: $('title').text(),\n        link,\n        language: $('html').attr('lang') as any,\n        item: items,\n    };\n}\n","sourceCodeStart":22,"sourceCodeEnd":57,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/pornhub/category-url.ts#L22-L57","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":"// before: /pornhub/category_url/video/cn.\n// after:  /pornhub/category_url/video/cn","handlingStrategy":"validation","validationCode":"import { isValidHost } from '@/utils/valid-host';\nfunction isValidLanguageSegment(lang: string): boolean {\n  return typeof lang === 'string' && lang.length > 0 && isValidHost(lang);\n}\nif (!isValidLanguageSegment(language)) {\n  // reject before building the pornhub URL\n}","typeGuard":"const isValidLanguageSegment = (lang: unknown): lang is string =>\n  typeof lang === 'string' && /^[\\dA-Z](?:[\\dA-Z-]{0,61}[\\dA-Z])?$/i.test(lang);","tryCatchPattern":"try {\n  // category_url handler\n} catch (e) {\n  if (e instanceof InvalidParameterError && /Invalid language/.test(e.message)) {\n    // surface allowed language subdomain codes\n  }\n}","preventionTips":["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."],"tags":["pornhub","invalid-parameter","validation","language","host"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}