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

[2.4] Hotfix - `isExpired` correct file path #171

Merged
merged 1 commit into from Nov 28, 2017

Conversation

@michalbundyra
Copy link
Contributor

michalbundyra commented Nov 28, 2017

Method was called from getContent with the full file path (see lines 36 and 43) and inside the method isExpired baseDir was added another time (see line 57), so as the result we have: "baseDir/baseDir/fileName.ext"

public function getContent($file)
{
$file = $this->baseDir . $file;
if ($this->baseDir && !Latte\Helpers::startsWith($this->normalizePath($file), $this->baseDir)) {
throw new \RuntimeException("Template '$file' is not within the allowed path '$this->baseDir'.");
} elseif (!is_file($file)) {
throw new \RuntimeException("Missing template file '$file'.");
} elseif ($this->isExpired($file, time())) {

public function isExpired($file, $time)
{
return @filemtime($this->baseDir . $file) > $time; // @ - stat may fail

Fix for 2.4 branch, but it should be also fixed on master.

  • bug fix? yes/no
  • new feature? yes/no
  • BC break? yes/no
  • doc PR: nette/docs#???
Method was called from getContent with the full file path
and inside the method baseDir was added another time,
so as the result we have: "baseDir/baseDir/fileName.ext"
@knight
knight approved these changes Nov 28, 2017
@dg

This comment has been minimized.

Copy link
Member

dg commented Nov 28, 2017

Thanks!

@dg dg merged commit 2010e6e into nette:v2.4 Nov 28, 2017
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls First build on v2.4 at 93.54%
Details
dg added a commit that referenced this pull request Nov 28, 2017
Method was called from getContent with the full file path
and inside the method baseDir was added another time,
so as the result we have: "baseDir/baseDir/fileName.ext"
@michalbundyra michalbundyra deleted the michalbundyra:hotfix/is-expired branch Nov 28, 2017
dg added a commit that referenced this pull request Nov 28, 2017
Method was called from getContent with the full file path
and inside the method baseDir was added another time,
so as the result we have: "baseDir/baseDir/fileName.ext"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.