Allow user to explicitly use a local file for html content. #687
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.