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

Allow user to explicitly use a local file for html content. #687

Merged
merged 1 commit into from Nov 21, 2022

Conversation

daum
Copy link
Contributor

@daum daum commented Nov 20, 2022

Sometimes it is necessary to have all the html contents in a local file rather than on a url or in a PHP string due to memory limits. The introduced function htmlFromFilePath makes it clear you are intending to set the html from a local file, and there for if the input is not being generated by the user themselves, they should validate the file path is allowed before allowing it to be used.

With 92cf16f I assume this functionality was removed out of safety concerns. However, for multiple projects we need to generate the PDF from HTML that is stored in a file that we incrementally build as some of HTML can larger than we want to store in memory. By having the explicit htmlFromFilePath it should be clear that a local file is going to be included, so the user should validate the path if they aren't providing it themselves.

I've added tests that verify the local file works and one that makes sure the file exists.

Sometimes it is necessary to have all the html contents in a local
file rather than on a url or in a PHP string due to memory limits.
The introduced function htmlFromFilePath makes it clear you are
intending to set the html from a local file, and there for
if the input is not being generated by the user themselves, they
should validate the file path is allowed before allowing it to be
used.
@freekmurze freekmurze merged commit 554c3e5 into spatie:main Nov 21, 2022
@freekmurze
Copy link
Member

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
2 participants