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

Cleanup FileSystemLoader (Followup to #775) #785

Merged
merged 1 commit into from
Sep 6, 2016

Conversation

robfrawley
Copy link
Collaborator

@robfrawley robfrawley commented Sep 6, 2016

This is a quick followup to #775.

The call to file_exists() is redundant and no longer required, as realpath() will already return false if the path does not exist.

Additionally, the call to ltrim() is no longer needed as realpath() will resolve the path properly, even if there are two slashes due to the root path and relative path concatenation.

Lastly, the ltrim() call may have also previously been a security consideration that would disallow the data_root being set to an empty string and absolute paths being passed as the relative path to find(). This is mitigated by the new check in the constructor that ensures data_root is not empty. A test for this edge-case is included.

(If someone really wants to push the boundaries of acceptable security, they can still set data_root to / and effectively pass absolute paths to the find() method, though this is a horrible idea... :-) )

Remove redundant file_exists check, remove unnessissary ltrim call

added empty root path check in FileSystem loader constructor
@lsmith77 lsmith77 added the State: Reviewing This item is being reviewed to determine if it should be accepted. label Sep 6, 2016
@lsmith77 lsmith77 merged commit 0cd8678 into liip:master Sep 6, 2016
@lsmith77 lsmith77 removed the State: Reviewing This item is being reviewed to determine if it should be accepted. label Sep 6, 2016
@robfrawley robfrawley deleted the bugfix-filesystem-loader branch January 9, 2017 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants