Compare commits

...

2 Commits

Author SHA1 Message Date
Administrator
0fd8dd0634 release: v2.3.8 2026-03-21 15:25:07 +01:00
Administrator
e22784cef8 🐛 fix(hosters): API JSON parse safety + URL-encode API key
- apiGet(): wrap res.json() in try-catch with descriptive error
  message when server returns HTML instead of JSON
- URL-encode apiKey in upload server lookup URL template
  (prevents broken URLs if key contains +, &, = chars)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:24:41 +01:00
2 changed files with 9 additions and 3 deletions

View File

@ -281,7 +281,13 @@ async function apiGet(url, signal) {
signal: controller.signal, signal: controller.signal,
redirect: 'follow' redirect: 'follow'
}); });
const data = await res.json(); let data;
try {
data = await res.json();
} catch {
const text = await res.text().catch(() => '');
throw new Error(`API-Antwort war kein JSON (HTTP ${res.status}): ${(text || '').slice(0, 200)}`);
}
if (data.status && [401, 403, 429, 500].includes(data.status)) { if (data.status && [401, 403, 429, 500].includes(data.status)) {
throw new Error(data.msg || data.message || JSON.stringify(data)); throw new Error(data.msg || data.message || JSON.stringify(data));
@ -300,7 +306,7 @@ async function getUploadServer(hosterName, hosterConfig, apiKey, signal) {
for (let attempt = 1; attempt <= SERVER_RETRY_ATTEMPTS; attempt++) { for (let attempt = 1; attempt <= SERVER_RETRY_ATTEMPTS; attempt++) {
for (const endpoint of hosterConfig.serverEndpoints) { for (const endpoint of hosterConfig.serverEndpoints) {
const url = `${hosterConfig.apiBase}${endpoint}?key=${apiKey}`; const url = `${hosterConfig.apiBase}${endpoint}?key=${encodeURIComponent(apiKey)}`;
try { try {
const data = await apiGet(url, signal); const data = await apiGet(url, signal);
const uploadUrl = extractUploadServerUrl(data, hosterConfig.apiBase); const uploadUrl = extractUploadServerUrl(data, hosterConfig.apiBase);

View File

@ -1,6 +1,6 @@
{ {
"name": "multi-hoster-uploader", "name": "multi-hoster-uploader",
"version": "2.3.7", "version": "2.3.8",
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously", "description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {