Skip to content

Commit

Permalink
Updating Media View to throw a 404 cakeError if the requested file do…
Browse files Browse the repository at this point in the history
…es not exist; thanks 'aidan' for suggested patch. Fixes #6120.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8066 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
jperras committed Feb 27, 2009
1 parent b8d21c6 commit f2b698a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cake/libs/view/media.php
Expand Up @@ -105,6 +105,11 @@ function render() {
} else {
$path = APP . $path . $id;
}

if (!file_exists($path)) {
header('Content-Type: text/html');
$this->cakeError('error404');
}

if (is_null($name)) {
$name = $id;
Expand All @@ -113,8 +118,8 @@ function render() {
if (is_array($mimeType)) {
$this->mimeType = array_merge($this->mimeType, $mimeType);
}

if (file_exists($path) && isset($extension) && isset($this->mimeType[$extension]) && connection_status() == 0) {
if (isset($extension) && isset($this->mimeType[$extension]) && connection_status() == 0) {
$chunkSize = 8192;
$buffer = '';
$fileSize = @filesize($path);
Expand Down

0 comments on commit f2b698a

Please sign in to comment.