auraphp / Aura.Filter

Validate and sanitize arrays and objects.
MIT License
159 stars 33 forks source link

Feature: PSR-7 upload validator #118

Closed jakejohns closed 8 years ago

jakejohns commented 8 years ago

Here's an attempt at implementing #111. Note, I did raise some concerns about this "combined" approach on that issue.

Thoughts?

jakejohns commented 8 years ago

@harikt Are you saying you think we should use the fileinfo extension to validate the MIME/MediaType rather than use the interfaces getClientMediaType method? Your comment is under the "extension" instead.

While I agree its a better mime validation, I wonder if it's a different scope being that it would not correspond to the output of methods provided by the interface.

Additionally, I wonder if a check on the entirety of the file name makes sense:

<?php
//...
protected function filename($value, $expr)
{
    $filename = $value->getClientFilename();
    return (bool) preg_match($expr, $filename);
}
harikt commented 8 years ago

@jakejohns you are correct. I was thinking about the mime/media type. It looks the psr-7 keeps the media type. But not sure whether it validates it.

pmjones commented 8 years ago

Well, hell. I failed to anticipate that this would need the PSR-7 interface, and in 2.x, we don't allow for external packages. :-/ At best this would have to go into a 3.x version, or perhaps as a non-official Aura package of filters.

Thoughts?

harikt commented 8 years ago

@pmjones why do we need to worry about moving to major version. I am :+1: for pushing major versions.

pmjones commented 8 years ago

/me nods

No reason not to start a 3.x branch now, I guess. I have just created one. @jakejohns if you want to rebase against that (or resubmit against that) feel free to do so!

jakejohns commented 8 years ago

I dont think I can just change the base of the pr, so closing here.