mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-04-29 02:37:27 +09:00
Merge commit from fork
Fix GHSA-7899-w6c4-vqc4
This commit is contained in:
commit
45153b4f08
@ -132,6 +132,7 @@ async function getOEmbedPlayer($: cheerio.CheerioAPI, pageUrl: string): Promise<
|
|||||||
export type GeneralScrapingOptions = {
|
export type GeneralScrapingOptions = {
|
||||||
lang?: string | null;
|
lang?: string | null;
|
||||||
userAgent?: string;
|
userAgent?: string;
|
||||||
|
followRedirects?: boolean;
|
||||||
responseTimeout?: number;
|
responseTimeout?: number;
|
||||||
operationTimeout?: number;
|
operationTimeout?: number;
|
||||||
contentLengthLimit?: number;
|
contentLengthLimit?: number;
|
||||||
@ -147,6 +148,7 @@ export async function general(_url: URL | string, opts?: GeneralScrapingOptions)
|
|||||||
const res = await scpaping(url.href, {
|
const res = await scpaping(url.href, {
|
||||||
lang: lang || undefined,
|
lang: lang || undefined,
|
||||||
userAgent: opts?.userAgent,
|
userAgent: opts?.userAgent,
|
||||||
|
followRedirects: opts?.followRedirects,
|
||||||
responseTimeout: opts?.responseTimeout,
|
responseTimeout: opts?.responseTimeout,
|
||||||
operationTimeout: opts?.operationTimeout,
|
operationTimeout: opts?.operationTimeout,
|
||||||
contentLengthLimit: opts?.contentLengthLimit,
|
contentLengthLimit: opts?.contentLengthLimit,
|
||||||
@ -251,7 +253,7 @@ export async function parseGeneral(_url: URL | string, res: Awaited<ReturnType<t
|
|||||||
const activityPub =
|
const activityPub =
|
||||||
$('link[rel="alternate"][type="application/activity+json"]').attr('href') || null;
|
$('link[rel="alternate"][type="application/activity+json"]').attr('href') || null;
|
||||||
|
|
||||||
const fediverseCreator: string | null =
|
const fediverseCreator: string | null =
|
||||||
$('meta[name=\'fediverse:creator\']').attr('content') || null;
|
$('meta[name=\'fediverse:creator\']').attr('content') || null;
|
||||||
|
|
||||||
// https://developer.mixi.co.jp/connect/mixi_plugin/mixi_check/spec_mixi_check/#toc-18-
|
// https://developer.mixi.co.jp/connect/mixi_plugin/mixi_check/spec_mixi_check/#toc-18-
|
||||||
|
@ -119,6 +119,7 @@ export const summaly = async (url: string, options?: SummalyOptions): Promise<Su
|
|||||||
lang: opts.lang,
|
lang: opts.lang,
|
||||||
userAgent: opts.userAgent,
|
userAgent: opts.userAgent,
|
||||||
responseTimeout: opts.responseTimeout,
|
responseTimeout: opts.responseTimeout,
|
||||||
|
followRedirects: opts.followRedirects,
|
||||||
operationTimeout: opts.operationTimeout,
|
operationTimeout: opts.operationTimeout,
|
||||||
contentLengthLimit: opts.contentLengthLimit,
|
contentLengthLimit: opts.contentLengthLimit,
|
||||||
contentLengthRequired: opts.contentLengthRequired,
|
contentLengthRequired: opts.contentLengthRequired,
|
||||||
|
@ -24,6 +24,7 @@ export type GotOptions = {
|
|||||||
body?: string;
|
body?: string;
|
||||||
headers: Record<string, string | undefined>;
|
headers: Record<string, string | undefined>;
|
||||||
typeFilter?: RegExp;
|
typeFilter?: RegExp;
|
||||||
|
followRedirects?: boolean;
|
||||||
responseTimeout?: number;
|
responseTimeout?: number;
|
||||||
operationTimeout?: number;
|
operationTimeout?: number;
|
||||||
contentLengthLimit?: number;
|
contentLengthLimit?: number;
|
||||||
@ -46,6 +47,7 @@ export function getGotOptions(url: string, opts?: GeneralScrapingOptions): Omit<
|
|||||||
'accept-language': opts?.lang ?? undefined,
|
'accept-language': opts?.lang ?? undefined,
|
||||||
},
|
},
|
||||||
typeFilter: /^(text\/html|application\/xhtml\+xml)/,
|
typeFilter: /^(text\/html|application\/xhtml\+xml)/,
|
||||||
|
followRedirects: opts?.followRedirects,
|
||||||
responseTimeout: opts?.responseTimeout,
|
responseTimeout: opts?.responseTimeout,
|
||||||
operationTimeout: opts?.operationTimeout,
|
operationTimeout: opts?.operationTimeout,
|
||||||
contentLengthLimit: opts?.contentLengthLimit,
|
contentLengthLimit: opts?.contentLengthLimit,
|
||||||
@ -114,6 +116,7 @@ export async function getResponse(args: GotOptions) {
|
|||||||
send: timeout,
|
send: timeout,
|
||||||
request: operationTimeout, // whole operation timeout
|
request: operationTimeout, // whole operation timeout
|
||||||
},
|
},
|
||||||
|
followRedirect: args.followRedirects,
|
||||||
agent,
|
agent,
|
||||||
http2: false,
|
http2: false,
|
||||||
retry: {
|
retry: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user