From 88241f5cd12d9e69ddc7e36a4ff44e35923e9fdc Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 6 Dec 2023 05:56:24 +0800 Subject: [PATCH 1/6] test: bump router test time range fix https://github.com/DIYgod/RSSHub/actions/runs/7104681085/job/19340228876 --- test/router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/router.js b/test/router.js index 26bead6e58d2f8..91c1db2d1435fc 100644 --- a/test/router.js +++ b/test/router.js @@ -17,7 +17,7 @@ async function checkRSS(response) { expect(date).toEqual(expect.any(String)); expect(Date.parse(date)).toEqual(expect.any(Number)); expect(new Date() - new Date(date)).toBeGreaterThan(-1000 * 60 * 60 * 24 * 5); - expect(new Date() - new Date(date)).toBeLessThan(1000 * 60 * 60 * 24 * 30 * 12 * 5); + expect(new Date() - new Date(date)).toBeLessThan(1000 * 60 * 60 * 24 * 30 * 12 * 10); }; const parsed = await parser.parseString(response.text); From 7da162041ff86e9d591e28db5de0b936a42e6e04 Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 6 Dec 2023 00:00:00 +0000 Subject: [PATCH 2/6] fix(core): duplicated path if the error is thrown from parameter (#13967) * fix(core): double namespace if the error is thrown from parameter * test: fix test case --- lib/middleware/onerror.js | 10 +++++++--- test/middleware/onerror.js | 4 ++-- test/utils/rand-user-agent.js | 12 +++++++----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/middleware/onerror.js b/lib/middleware/onerror.js index a29f59b7a74433..3a966029521906 100644 --- a/lib/middleware/onerror.js +++ b/lib/middleware/onerror.js @@ -39,9 +39,13 @@ module.exports = async (ctx, next) => { }); } } catch (err) { - // Append v2 route path - ctx.request.path = (ctx.mountPath ?? '') + ctx.request.path; - ctx._matchedRoute = ctx._matchedRoute ? (ctx.mountPath ?? '') + ctx._matchedRoute : ctx.request.path; + if (err instanceof Error && !err.stack.split('\n')[1].includes('lib/middleware/parameter.js')) { + // Append v2 route path if a route throws an error + // since koa-mount will remove the mount path from ctx.request.path + // https://github.com/koajs/mount/issues/62 + ctx.request.path = (ctx.mountPath ?? '') + ctx.request.path; + ctx._matchedRoute = ctx._matchedRoute ? (ctx.mountPath ?? '') + ctx._matchedRoute : ctx._matchedRoute; + } let message = err; if (err.name && (err.name === 'HTTPError' || err.name === 'RequestError')) { diff --git a/test/middleware/onerror.js b/test/middleware/onerror.js index f2ca6004807d40..e92fcea13a31bb 100644 --- a/test/middleware/onerror.js +++ b/test/middleware/onerror.js @@ -59,13 +59,13 @@ describe('v2 route throws an error', () => { expect(value).toBe('7'); break; case 'Hot Routes:': - expect(value).toBe('4 /test/:id
1 /test/slow
1 /thisDoesNotExist
'); + expect(value).toBe('4 /test/:id
'); break; case 'Hot Paths:': expect(value).toBe('2 /test/error
2 /test/slow
1 /test/httperror
1 /thisDoesNotExist
1 /
'); break; case 'Hot Error Routes:': - expect(value).toBe('3 /test/:id
1 /test/slow
1 /thisDoesNotExist
'); + expect(value).toBe('3 /test/:id
'); break; case 'Hot Error Paths:': expect(value).toBe('2 /test/error
1 /test/httperror
1 /test/slow
1 /thisDoesNotExist
'); diff --git a/test/utils/rand-user-agent.js b/test/utils/rand-user-agent.js index 01b2cc5b90be40..d8a44301f821a6 100644 --- a/test/utils/rand-user-agent.js +++ b/test/utils/rand-user-agent.js @@ -33,15 +33,17 @@ describe('rand-user-agent', () => { }); it('should match ua configurated', async () => { - const response1 = await got('https://httpbingo.org/user-agent'); - expect(response1.data['user-agent']).toBe(config.ua); + nock('https://rsshub.test') + .get('/test') + .reply(function () { + return [200, { ua: this.req.headers['user-agent'] }]; + }); - const response2 = await got('https://httpbingo.org/user-agent', { + const resonse = await got('https://rsshub.test/test', { headers: { 'user-agent': mobileUa, }, }); - expect(response2.data['user-agent']).toBe(mobileUa); - expect(response2.data['user-agent']).not.toBe(config.ua); + expect(resonse.data.ua).toBe(mobileUa); }); }); From 9b67dd43ae0acd76d8c70945e10e76e44c63f17b Mon Sep 17 00:00:00 2001 From: TonyRL Date: Wed, 6 Dec 2023 00:06:41 +0000 Subject: [PATCH 3/6] chore: remove duplicated semgrep e.g., https://github.com/DIYgod/RSSHub/actions/runs/7093681885/job/19307555786#step:4:27 --- .github/workflows/semgrep.yml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml index 4a4f76766450f0..41950d0e02e457 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/semgrep.yml @@ -21,25 +21,13 @@ jobs: runs-on: ubuntu-latest container: image: returntocorp/semgrep - if: (github.actor != 'dependabot[bot]') - steps: - - uses: actions/checkout@v4 - - run: semgrep ci - env: - SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} - - semgrep-github: - name: Scan - runs-on: ubuntu-latest - container: - image: returntocorp/semgrep - if: (github.actor != 'dependabot[bot]') + if: (github.triggering_actor != 'dependabot[bot]') permissions: contents: read security-events: write steps: - uses: actions/checkout@v4 - - run: semgrep ci --sarif --output=semgrep.sarif + - run: semgrep ci --sarif > semgrep.sarif env: SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} - name: Upload SARIF file for GitHub Advanced Security Dashboard From a09f33dc4a0794bb91b88ae26aaedb4eb21329d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 08:13:26 +0800 Subject: [PATCH 4/6] chore(deps-dev): bump @stylistic/eslint-plugin-js from 1.4.1 to 1.5.0 (#13966) * chore(deps-dev): bump @stylistic/eslint-plugin-js from 1.4.1 to 1.5.0 Bumps [@stylistic/eslint-plugin-js](https://github.com/eslint-stylistic/eslint-stylistic/tree/HEAD/packages/eslint-plugin-js) from 1.4.1 to 1.5.0. - [Release notes](https://github.com/eslint-stylistic/eslint-stylistic/releases) - [Commits](https://github.com/eslint-stylistic/eslint-stylistic/commits/v1.5.0/packages/eslint-plugin-js) --- updated-dependencies: - dependency-name: "@stylistic/eslint-plugin-js" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * chore: fix pnpm install --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 26eb976a398cd1..1b3829bf3813d7 100644 --- a/package.json +++ b/package.json @@ -150,7 +150,7 @@ }, "devDependencies": { "@microsoft/eslint-formatter-sarif": "3.0.0", - "@stylistic/eslint-plugin-js": "1.4.1", + "@stylistic/eslint-plugin-js": "1.5.0", "@types/aes-js": "3.1.4", "@types/crypto-js": "4.2.1", "@types/eslint": "8.44.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f9716f79c489a0..51a3d6f15a87ba 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -203,8 +203,8 @@ devDependencies: specifier: 3.0.0 version: 3.0.0 '@stylistic/eslint-plugin-js': - specifier: 1.4.1 - version: 1.4.1(eslint@8.55.0) + specifier: 1.5.0 + version: 1.5.0(eslint@8.55.0) '@types/aes-js': specifier: 3.1.4 version: 3.1.4 @@ -1316,8 +1316,8 @@ packages: '@sinonjs/commons': 3.0.0 dev: true - /@stylistic/eslint-plugin-js@1.4.1(eslint@8.55.0): - resolution: {integrity: sha512-WXHPEVw5PB7OML7cLwHJDEcCyLiP7vzKeBbSwmpHLK0oh0JYkoJfTg2hEdFuQT5rQxFy3KzCy9R1mZ0wgLjKrA==} + /@stylistic/eslint-plugin-js@1.5.0(eslint@8.55.0): + resolution: {integrity: sha512-TuGQv1bsIshkbJUInCewp4IUWy24W5RFiVNMV0quPSkuZ8gsYoqq6kLHvvaxpjxN9TvwSoOIwnhgrYKei2Tgcw==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: '>=8.40.0' From d93c99ea393f0c36876b86d944536bc5dab5ed2b Mon Sep 17 00:00:00 2001 From: limfoo <34062417+limfoo@users.noreply.github.com> Date: Wed, 6 Dec 2023 09:54:43 +0800 Subject: [PATCH 5/6] docs: Update InstanceList.tsx (#13968) * Update InstanceList.tsx * Update website/src/components/InstanceList.tsx --------- --- website/src/components/InstanceList.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/website/src/components/InstanceList.tsx b/website/src/components/InstanceList.tsx index f302aab0eaf8dc..e4dd388c1b3605 100644 --- a/website/src/components/InstanceList.tsx +++ b/website/src/components/InstanceList.tsx @@ -41,6 +41,11 @@ export default function InstanceList(): JSX.Element { location: '🇺🇸', maintainer: '思维悦动', maintainerUrl: 'https://friesport.ac.cn', + }, { + url: 'https://rsshub.atgw.io', + location: '🇺🇸', + maintainer: 'limfoo', + maintainerUrl: 'https://blog.limfoo.io', }] return ( From 360fc48d90569a0e3d24d7d663f784be8cc1a1ba Mon Sep 17 00:00:00 2001 From: denis-ya Date: Wed, 6 Dec 2023 15:02:09 +0300 Subject: [PATCH 6/6] fix(route): news/fisher-spb code page was fixed (#13971) * code page was fixed * iconv was removed --- lib/v2/fisher-spb/news.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/v2/fisher-spb/news.js b/lib/v2/fisher-spb/news.js index fd28abc395e005..2cf040792443e9 100644 --- a/lib/v2/fisher-spb/news.js +++ b/lib/v2/fisher-spb/news.js @@ -1,6 +1,5 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); -const iconv = require('iconv-lite'); const { parseDate } = require('@/utils/parse-date'); const { art } = require('@/utils/render'); const path = require('path'); @@ -16,7 +15,7 @@ module.exports = async (ctx) => { responseType: 'buffer', }); - const $ = cheerio.load(iconv.decode(response.data, 'windows-1251')); + const $ = cheerio.load(response.data); const descBuilder = (element) => { const content = cheerio.load(`

${$('.news-message-text', element).html()}

`).root();