-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Allow to import template files relative to root #2
Conversation
Note: default root is /joomlatools-pages
@raeldc Added additional check to prevent directory traversal attempts outside of the pages root. |
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.
Tested. Everything works as the ticket described. Only broke it by recursively importing files - which can be fixed on the framework level.
@raeldc I have added basic support for detecting recursion. Can you check if that solves it for your use-case? |
Note: This PR required joomlatools/joomlatools-framework#151 for testing
Moved the /pages folder one level lower and make it a required folder. The minimum structure now is
The root folder can be configured in the page:// locator.
The changes allow to import templates relative to the root folder, to test use:
Following imports are resolved against the root folder, eg joomlatools-files.
Following imports are resolved relative from the folder the template is imported into.
Following imports are resolved relative from the folder the template is imported into. The last allow to jump out of the root folder, haven't tested this yet, probably need to harden for this.
Examples:
<?= import('/templates/file'); ?>
Will load a partial from root, eg /joomlatools-pages/
<?= import('../file'); ?>
Will load a partial relative from the file the import is used into
Notes:
As part of the changes made in: #9 a page template no longer requires a '.html' suffix.