Skip to content

Fix external link handling in SimpleLinkService#221

Merged
TaTo30 merged 2 commits into
TaTo30:masterfrom
carret1268:fix-link-attributes
Mar 6, 2026
Merged

Fix external link handling in SimpleLinkService#221
TaTo30 merged 2 commits into
TaTo30:masterfrom
carret1268:fix-link-attributes

Conversation

@carret1268

Copy link
Copy Markdown
Contributor

While working with vue-pdf I noticed that external links rendered from PDFs did not set target and rel attributes on the generated anchor elements. This stemmed from an empty implementation of addLinkAttributes in SimpleLinkService.

This PR implements the following improvements:

  • Validate URLs before assigning to anchor elements
  • Restrict allowed protocols to http/https/mailto/tel
  • Respect the newWindow parameter
  • Allow configurable externalLinkTarget and externalLinkRel
  • SSR-safe base URL fallback when window is unavailable

Build and tests pass locally. Tested locally with PDFs containing external hyperlinks.

- validate URL before assigning to anchor
- restrict protocols to http/https/mailto/tel
- support newWindow parameter
- add configurable externalLinkTarget and externalLinkRel
@TaTo30 TaTo30 merged commit 36757f2 into TaTo30:master Mar 6, 2026
@TaTo30

TaTo30 commented Mar 6, 2026

Copy link
Copy Markdown
Owner

Thanks!

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