Fixes path, image, and bibliography issues #7

Merged
AlexKucera merged 19 commits from windows_path_fix into master 2025-11-05 09:28:22 +01:00
Showing only changes of commit 4eb52d11c0 - Show all commits
+7 -3
View File
2
@@ -115,9 +115,13 @@ export class EmbedProcessor {
if (response.statusCode === 301 || response.statusCode === 302) {
const redirectUrl = response.headers.location;
if (redirectUrl) {
console.log(`Export: Following redirect to: ${redirectUrl}`);
// Recursively follow redirect
this.downloadRemoteImage(redirectUrl, tempDir).then(resolve);
// Resolve relative redirects against the original request URL
// This handles both absolute URLs (e.g., "https://example.com/img.png")
// and relative URLs (e.g., "/assets/img.png" or "../img.png")
const absoluteRedirectUrl = new URL(redirectUrl, imageUrl).href;
console.log(`Export: Following redirect to: ${absoluteRedirectUrl}`);
// Recursively follow redirect with resolved absolute URL
this.downloadRemoteImage(absoluteRedirectUrl, tempDir).then(resolve);
return;
}
coderabbitai[bot] commented 2025-11-04 11:24:46 +01:00 (Migrated from github.com)
Review

⚠️ Potential issue | 🟠 Major

Handle relative redirects when downloading images.

Redirects such as Location: /assets/img.png are valid but new URL(redirectUrl) will throw without the original request as a base, causing every relative redirect download to fail. Pass the original URL to new URL(...) (or otherwise resolve before recursing) so remote images behind relative redirects work.

🤖 Prompt for AI Agents
In src/plugin/EmbedProcessor.ts around lines 112 to 118, the code assumes
Location is an absolute URL and calls new URL(redirectUrl) which throws for
relative redirects; resolve redirectUrl against the original request URL (e.g.,
use new URL(redirectUrl, originalRequestUrl) or URL.resolve equivalent) to
produce an absolute URL, then pass that resolved absolute URL into
this.downloadRemoteImage(...) when recursing so relative Location headers (like
"/assets/img.png") are handled correctly.

✅ Addressed in commits 7ac9e1f to 4eb52d1

_⚠️ Potential issue_ | _🟠 Major_ **Handle relative redirects when downloading images.** Redirects such as `Location: /assets/img.png` are valid but `new URL(redirectUrl)` will throw without the original request as a base, causing every relative redirect download to fail. Pass the original URL to `new URL(...)` (or otherwise resolve before recursing) so remote images behind relative redirects work. <details> <summary>🤖 Prompt for AI Agents</summary> ``` In src/plugin/EmbedProcessor.ts around lines 112 to 118, the code assumes Location is an absolute URL and calls new URL(redirectUrl) which throws for relative redirects; resolve redirectUrl against the original request URL (e.g., use new URL(redirectUrl, originalRequestUrl) or URL.resolve equivalent) to produce an absolute URL, then pass that resolved absolute URL into this.downloadRemoteImage(...) when recursing so relative Location headers (like "/assets/img.png") are handled correctly. ``` </details> <!-- fingerprinting:phantom:medusa:sabertoothed --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commits 7ac9e1f to 4eb52d1
}