-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
FileResponse: added some checks #238
Conversation
@@ -40,6 +40,9 @@ public function __construct(string $file, string $name = null, string $contentTy | |||
if (!is_file($file)) { | |||
throw new Nette\Application\BadRequestException("File '$file' doesn't exist."); | |||
} | |||
if (!is_readable($file)) { | |||
throw new Nette\Application\BadRequestException("File '$file' doesn't readable."); |
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.
is not readable sounds better
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.
I'm not sure how useful the is_readable
check is when you check fopen
result later anyway.
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.
@JanTvrdik The sooner the better :-) But I don't insist on it.
@@ -88,6 +91,9 @@ public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $htt | |||
|
|||
$filesize = $length = filesize($this->file); | |||
$handle = fopen($this->file, 'r'); | |||
if (!$handle) { | |||
throw new Nette\Application\BadRequestException("Cannot make handle of '{$this->file}'."); | |||
} |
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.
Cannot open file?
…e entire application.
f14221c
to
b896510
Compare
7fe78c1
to
8f1bb54
Compare
If the file has strict privileges, it will crash the entire application.