jonathangeiger / kohana-jelly

See the link below for the most up-to-date code
https://github.com/creatoro/jelly
MIT License
146 stars 34 forks source link

Jelly_Field_File - The file is saved even with an invalid type #164

Closed Neurergus closed 14 years ago

Neurergus commented 14 years ago

Using the unstable version, the _upload function adds the error to the validator object, but doesn't stop the file from being saved.

See this code:

    [...]
    // Check to see if it's a valid type
    if ($this->types AND ! Upload::type($file, $this->types))
    {
        $array->error($field, 'Upload::type');
    }

    // Sanitize the filename
    $file['name'] = preg_replace('/[^a-z0-9-\.]/', '-', strtolower($file['name']));

    // Strip multiple dashes
    $file['name'] = preg_replace('/-{2,}/', '-', $file['name']);

    // Upload a file?
    if (FALSE !== ($filename = Upload::save($file, NULL, $this->path)))
    {
    [...]

I think there should be a return after adding the error:

    if ($this->types AND ! Upload::type($file, $this->types))
    {
        $array->error($field, 'Upload::type');
        return;
    }
jonathangeiger commented 14 years ago

Closed by fa7e49a1635ab8fb8b1325d36c565bbb137fe858. Thanks Cataphractus!