DIYgod/RSSHub · error · InvalidParameterError

Invalid pub

Error message

Invalid pub

What it means

The AIP (American Institute of Physics) route builds the URL `https://pubs.aip.org/${pub}/${jrn}/issue`. isValidHost rejects `pub` values that are not a clean single DNS label, preventing path/host injection (dots, slashes, etc.) into the URL.

Source

Thrown at lib/routes/aip/journal-pupp.ts:17

import { load } from 'cheerio';

import { config } from '@/config';
import InvalidParameterError from '@/errors/types/invalid-parameter';
import cache from '@/utils/cache';
import playwright from '@/utils/playwright';
import { isValidHost } from '@/utils/valid-host';

import { playwrightGet, renderDesc } from './utils';

const handler = async (ctx) => {
    const pub = ctx.req.param('pub');
    const jrn = ctx.req.param('jrn');
    const host = 'https://pubs.aip.org';
    const jrnlUrl = `${host}/${pub}/${jrn}/issue`;
    if (!isValidHost(pub)) {
        throw new InvalidParameterError('Invalid pub');
    }

    // use Playwright due to the obstacle by cloudflare challenge
    const context = await playwright();

    const { jrnlName, list } = await cache.tryGet(
        jrnlUrl,
        async () => {
            const response = await playwrightGet(jrnlUrl, context);
            const $ = load(response);
            const jrnlName = $('.header-journal-title').text();
            const list = $('.card')
                .toArray()
                .map((item) => {
                    $(item).find('.access-text').remove();
                    const title = $(item).find('.hlFld-Title').text();
                    const authors = $(item).find('.entryAuthor.all').text();
                    const img = $(item).find('img').attr('src');

View on GitHub (pinned to bed535e087)

Solutions

  1. Pass only the publisher/path segment as it appears in the route example — a single label with no dots or slashes.
  2. Check the route's `example` field for the canonical pub/jrn pair.
  3. Confirm `jrn` is also a single path segment.

Example fix

// before
/aip/journal-pupp/pubs.aip.org/physicstoday
// after
/aip/journal-pupp/<publisher-label>/physicstoday   // single-label pub
Defensive patterns

Strategy: validation

Validate before calling

import { isValidHost } from '@/utils/valid-host';
function validAipPub(pub) {
  return isValidHost(pub) && /^[a-z0-9-]+$/i.test(pub);
}

Type guard

function isAipPubLabel(p): p is string {
  return typeof p === 'string' && /^[a-z0-9-]+$/i.test(p) && !p.includes('.') && !p.includes('/');
}

Prevention

When it happens

Trigger: Calling /aip/journal-pupp/:pub/:jrn where `pub` contains dots, slashes, or other characters that make it not a valid single-label hostname — e.g. passing the full URL or a multi-segment path.

Common situations: Passing 'pubs.aip.org' as pub; including a leading slash; using a journal code where the publisher code should go.

Related errors


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