Skip to content

Secure remote images: HTTPS default, --no-external, friendlier errors - #10

Merged
0xtlt merged 3 commits into
mainfrom
t/skip-remote-images-ccdc
Jul 29, 2026
Merged

Secure remote images: HTTPS default, --no-external, friendlier errors#10
0xtlt merged 3 commits into
mainfrom
t/skip-remote-images-ccdc

Conversation

@0xtlt

@0xtlt 0xtlt commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

md2pdf README.md failed because Typst tried to fetch shield/CI badge URLs and has no network access. This PR downloads remote images safely by default and improves failure messages.

Changes

  • Default allow external HTTPS: download remote Markdown images over HTTPS and embed them as virtual Typst assets
  • --no-external: skip all remote downloads; keep alt text and emit md2pdf: warning: lines
  • --allow-http: opt into cleartext http:// downloads (blocked by default, including HTTP redirects)
  • Missing/failed images: warn and continue instead of aborting PDF generation
  • Friendlier PDF errors: replace raw TypstSource([SourceDiagnostic { … }]) dumps with short human-readable messages

Usage

md2pdf README.md                       # HTTPS remotes by default
md2pdf README.md --no-external         # skip remotes, warn, still succeed
md2pdf doc.md --allow-http             # also allow cleartext http:// images

Verification

  • cargo test --locked
  • cargo clippy --all-targets -- -D warnings
  • cargo doc --no-deps
  • README conversion succeeds with and without --no-external
  • Cleartext http:// images warn and are skipped unless --allow-http
Open in Web Open in Cursor 

cursoragent and others added 2 commits July 29, 2026 16:31
Omit http(s) and protocol-relative images instead of passing them to
Typst (which has no network access), while keeping alt text so linked
badges still render as clickable labels.

Co-authored-by: Thomas <0xtlt@users.noreply.github.com>
Download remote Markdown images by default into virtual Typst assets,
skip them with warnings when --no-external is set or a fetch fails, and
omit missing local images instead of failing. Humanize Typst diagnostics
so users see short messages rather than SourceDiagnostic dumps.

Co-authored-by: Thomas <0xtlt@users.noreply.github.com>
@cursor cursor Bot changed the title Fix PDF failure on remote README badge images Add --no-external policy and friendlier image errors Jul 29, 2026
Block cleartext http:// image downloads by default, including insecure
redirect targets, while keeping HTTPS remote fetches enabled. Opt in with
--allow-http; skipped URLs still warn and keep alt text.

Co-authored-by: Thomas <0xtlt@users.noreply.github.com>
@cursor cursor Bot changed the title Add --no-external policy and friendlier image errors Secure remote images: HTTPS default, --no-external, friendlier errors Jul 29, 2026
@0xtlt
0xtlt marked this pull request as ready for review July 29, 2026 16:43
@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@0xtlt
0xtlt merged commit fb27052 into main Jul 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants