Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): URLをデコードしてからリクエストを送信するように #15015

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Fix: 画面サイズが変わった際にナビゲーションバーが自動で折りたたまれない問題を修正

### Server
- Fix: URLをデコードしてからリクエストを送信するように
- Fix: ユーザーのプロフィール画面をアドレス入力などで直接表示した際に概要タブの描画に失敗する問題の修正( #15032 )


Expand Down
5 changes: 3 additions & 2 deletions packages/backend/src/core/HttpRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ export class HttpRequestService {
},
): Promise<Response> {
const timeout = args.timeout ?? 5000;
const decodedUrl = decodeURIComponent(url);

const controller = new AbortController();
setTimeout(() => {
Expand All @@ -291,15 +292,15 @@ export class HttpRequestService {

const isLocalAddressAllowed = args.isLocalAddressAllowed ?? false;

const res = await fetch(url, {
const res = await fetch(decodedUrl, {
method: args.method ?? 'GET',
headers: {
'User-Agent': this.config.userAgent,
...(args.headers ?? {}),
},
body: args.body,
size: args.size ?? 10 * 1024 * 1024,
agent: (url) => this.getAgentByUrl(url, false, isLocalAddressAllowed),
agent: (decodedUrl) => this.getAgentByUrl(decodedUrl, false, isLocalAddressAllowed),
signal: controller.signal,
});

Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/server/api/endpoints/fetch-rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Parser from 'rss-parser';
import { Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { HttpRequestService } from '@/core/HttpRequestService.js';
import { URL } from 'url';

const rssParser = new Parser();

Expand Down
Loading