Repository navigation
PDF export keeps only web and mail links #1221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8fd1c17
8c4907a
afb52ae
274b626
920925a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,7 @@ use craft_pdf::write::{self, Metadata, Writer, backend as krilla}; | |||||
|
|
||||||
| use deckcraft_fonts::FontDb; | ||||||
| use deckcraft_model::Presentation; | ||||||
| use deckcraft_model::text::Action as ClickAction; | ||||||
| use deckcraft_model::text::{Action as ClickAction, safe_url}; | ||||||
| use deckcraft_render::{PlacedText, RenderOpts}; | ||||||
| use krilla::action::{Action, LinkAction}; | ||||||
| use krilla::annotation::{Annotation, LinkAnnotation, Target}; | ||||||
|
|
@@ -565,7 +565,9 @@ impl Exporter<'_> { | |||||
| slide.and_then(|s| page_of.get(&s)).map(|p| Target::Destination(XyzDestination::new(*p, Point::from_xy(0.0, 0.0)).into())) | ||||||
| }; | ||||||
| let target = match &l.link.action { | ||||||
| ClickAction::Url { url } => Some(Target::Action(Action::Link(LinkAction::new(url.clone())))), | ||||||
| // Only the links the slide show opens (web and mail): a reader of the file gets the rest | ||||||
| // as plain text. | ||||||
| ClickAction::Url { url } if safe_url(url) => Some(Target::Action(Action::Link(LinkAction::new(url.clone())))), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔎 Supported by static analysis
Trim the URL before writing the PDF annotation.
🐛 Suggested fix
Committable suggestion
|
||||||
| ClickAction::Slide { slide } => goto(pres.slides.iter().position(|x| x.id == *slide)), | ||||||
| ClickAction::NextSlide => goto(Some(i + 1)), | ||||||
| ClickAction::PreviousSlide => goto(i.checked_sub(1)), | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Require a host in HTTP(S) URLs.
https:///notes.pdfpasses this check because the remainder starts with//and contains another byte. It has no host, yetsafe_urlmarks it safe to open and PDF export creates a link annotation. HTTP(S) URIs require a nonempty host. Parse the authority and reject an empty host; add a hostless case to the test. (rfc-editor.org)