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 35a5249607 - Show all commits
+4 -3
View File
1
@@ -105,12 +105,13 @@ export class EmbedProcessor {
const outputPath = path.join(tempDir, finalFileName);
coderabbitai[bot] commented 2025-11-04 11:24:46 +01:00 (Migrated from github.com)
Review

⚠️ Potential issue | 🟠 Major

Preserve original image extensions instead of forcing .png.

When a remote file ends with something like .svg, we append .png without converting the contents. That leaves us with an SVG payload masquerading as PNG, so Typst/Pandoc will fail to decode the asset. Please keep the on-disk extension if one is present (at least include .svg, .ico, etc. in validExtensions, or only fall back to .png when the URL truly lacks an extension). Based on learnings

🤖 Prompt for AI Agents
In src/plugin/EmbedProcessor.ts around lines 96 to 103, the current logic forces
a .png when the file extension isn't in a small whitelist, which causes
mismatched on-disk extensions for assets like .svg or .ico; change the logic to
preserve any existing extension returned by path.extname (after normalizing and
stripping query/fragments) and only append .png when no extension is present (or
the ext is empty), or alternatively expand the validExtensions list to include
common types like .svg, .ico, .avif, .svgz; ensure you normalize ext via
toLowerCase() and treat extensions with query strings correctly so the
finalFileName uses the original extension when present and only falls back to
.png when the URL truly lacks one.

✅ Addressed in commits 7ac9e1f to 4eb52d1

_⚠️ Potential issue_ | _🟠 Major_ **Preserve original image extensions instead of forcing `.png`.** When a remote file ends with something like `.svg`, we append `.png` without converting the contents. That leaves us with an SVG payload masquerading as PNG, so Typst/Pandoc will fail to decode the asset. Please keep the on-disk extension if one is present (at least include `.svg`, `.ico`, etc. in `validExtensions`, or only fall back to `.png` when the URL truly lacks an extension). Based on learnings <details> <summary>🤖 Prompt for AI Agents</summary> ``` In src/plugin/EmbedProcessor.ts around lines 96 to 103, the current logic forces a .png when the file extension isn't in a small whitelist, which causes mismatched on-disk extensions for assets like .svg or .ico; change the logic to preserve any existing extension returned by path.extname (after normalizing and stripping query/fragments) and only append .png when no extension is present (or the ext is empty), or alternatively expand the validExtensions list to include common types like .svg, .ico, .avif, .svgz; ensure you normalize ext via toLowerCase() and treat extensions with query strings correctly so the finalFileName uses the original extension when present and only falls back to .png when the URL truly lacks one. ``` </details> <!-- fingerprinting:phantom:medusa:sabertoothed --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commits 7ac9e1f to 4eb52d1
// Select appropriate protocol
const protocol = imageUrl.startsWith('https') ? https : http;
// Select appropriate protocol based on parsed URL (handles case-insensitive schemes)
const protocol = urlObj.protocol === 'https:' ? https : http;
console.log(`Export: Downloading remote image: ${imageUrl}`);
const request = protocol.get(imageUrl, (response) => {
// Use parsed URL object for the request to ensure correct protocol handling
const request = protocol.get(urlObj, (response) => {
// Handle redirects
if (response.statusCode === 301 || response.statusCode === 302) {
const redirectUrl = response.headers.location;
1