Skip to content
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

dev/core#3034 Ensure that filename contains the file extension for PDFs #22532

Merged
merged 1 commit into from
Mar 28, 2022

Conversation

seamuslee001
Copy link
Contributor

Overview

This ensures that the file extension is within the content-disposition header when downloading a pdf file

Before

File extension may not be in the header

After

File extension is in the header and part of the file name

ping @eileenmcnaughton @demeritcowboy @colemanw

@civibot
Copy link

civibot bot commented Jan 17, 2022

(Standard links)

@civibot civibot bot added the master label Jan 17, 2022
@demeritcowboy
Copy link
Contributor

demeritcowboy commented Jan 17, 2022

Thanks @seamuslee001 just I'm not sure this is the correct solution, since it might double-append .pdf in some cases.

I'm also not sure the reported reproduction steps are, or should be, a supported operation:

Click 'edit' on a Mail merge activity
Click preview or download.

Maybe, just wondering if that ever was supported or is a weird artifact of the changes in 5.43+

@seamuslee001
Copy link
Contributor Author

@demeritcowboy
Copy link
Contributor

demeritcowboy commented Jan 17, 2022

Except it does when you're initially creating the file. And I'm trying to even reproduce the issue and can't. Can you reproduce the reported issue?

Also noting that oddly the buttons only appear on edit if you have popups enabled but that's only relevant to reproducing. Update: The buttons appearing seems to depend which version of a link you follow, e.g. from the recent items list or not.

@demeritcowboy demeritcowboy added the needs-steps-to-replicate It is unclear how to replicate this label Mar 17, 2022
@demeritcowboy
Copy link
Contributor

I tried again to reproduce and can't. Have made comment in ticket: https://lab.civicrm.org/dev/core/-/issues/3034#note_70503

@masetto
Copy link
Contributor

masetto commented Mar 28, 2022

@demeritcowboy I think @seamuslee001 modification is right for these reasons:

  1. On line 36 of CRM/Utils/PDF/Utils.php it is implicitly written that the $fileName must contain the file extension ($fileName = 'civicrm.pdf', "Ex: "HelloWorld.pdf")

  2. If you use DOMPDF, on line 191 the file extension is removed:

    // CRM-19183 remove .pdf extension from filename
    $fileName = basename($fileName, ".pdf");
  1. The problem occurs when you use "wkhtmltopdf" instead of DOMPDF: here the file extension is not added!

@demeritcowboy
Copy link
Contributor

jenkins retest this please

@demeritcowboy demeritcowboy removed the needs-steps-to-replicate It is unclear how to replicate this label Mar 28, 2022
@demeritcowboy
Copy link
Contributor

Agreed.

I might do a followup with at least a code comment because I think this happened because it's not obvious what gets set/removed where and the differences. And it turns out it's also different between firefox and chrome.

@demeritcowboy demeritcowboy merged commit 631addc into civicrm:master Mar 28, 2022
@eileenmcnaughton eileenmcnaughton deleted the dev_core_3034 branch March 29, 2022 01:14
@jaapjansma jaapjansma mentioned this pull request Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants