Fixes #26010 - Template Part Not Found message on Windows server#26772
Merged
youknowriad merged 8 commits intoWordPress:masterfrom Nov 26, 2020
Merged
Fixes #26010 - Template Part Not Found message on Windows server#26772youknowriad merged 8 commits intoWordPress:masterfrom
youknowriad merged 8 commits intoWordPress:masterfrom
Conversation
…, reproducable ordering
…, reproducable ordering
…ns\gutenberg-source
…Otherwise Windows may return 2.
6 tasks
youknowriad
reviewed
Nov 25, 2020
| // render the corresponding file content. | ||
| $template_part_file_path = get_stylesheet_directory() . '/block-template-parts/' . $attributes['slug'] . '.html'; | ||
| if ( 0 === validate_file( $template_part_file_path ) && file_exists( $template_part_file_path ) ) { | ||
| if ( 0 === validate_file( $attributes['slug'] ) && file_exists( $template_part_file_path ) ) { |
Contributor
There was a problem hiding this comment.
Do you know what's the purpose of this validate_file call? Why not just remove it?
Contributor
Author
There was a problem hiding this comment.
It's to stop directory traversal.
youknowriad
approved these changes
Nov 26, 2020
Contributor
youknowriad
left a comment
There was a problem hiding this comment.
Thanks for being patient here even for a small change. I appreciate it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
In
gutenberg_render_block_core_template_partwhen trying to find the template part from the theme's files, rather than callingvalidate_file()against the full file name, we just validate the slug part. This overcomes the problem that in a Windows server the return code is 2 when the file name contains the drive letter ( egC:).How has this been tested?
Screenshots
Without the fix the Template Part Not Found message is displayed twice.

With the fix the header and footer templates are found.
Types of changes
Bug fix for #26010. This only fixes the problem as reported.
It does not improve on the message "Template Part Not Found".
That's for later.
Checklist: