From f9feaa41ce77b14c3782ea64acc74361780f6853 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Thu, 14 Dec 2023 22:43:36 +0000 Subject: [PATCH] tumblr: stricter subdomain parsing --- src/modules/processing/services/tumblr.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modules/processing/services/tumblr.js b/src/modules/processing/services/tumblr.js index 7ae7336c..f978e5a4 100644 --- a/src/modules/processing/services/tumblr.js +++ b/src/modules/processing/services/tumblr.js @@ -1,9 +1,12 @@ +import psl from "psl"; import { genericUserAgent } from "../../config.js"; export default async function(obj) { - let html = await fetch(`https://${ - obj.user ? obj.user : obj.url.split('.')[0].replace('https://', '') - }.tumblr.com/post/${obj.id}`, { + const { subdomain } = psl.parse(obj.url); + if (subdomain?.includes('.')) + return { error: 'ErrorBrokenLink' } + + let html = await fetch(`https://${obj.user ?? subdomain}.tumblr.com/post/${obj.id}`, { headers: { "user-agent": genericUserAgent } }).then((r) => { return r.text() }).catch(() => { return false });