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

Resolve issue #21 #22

Merged
merged 1 commit into from
Oct 6, 2015
Merged

Resolve issue #21 #22

merged 1 commit into from
Oct 6, 2015

Conversation

nyamsprod
Copy link
Member

Improve Mimetype validation for Data Uris Path component.

  • The mimetype is not validate per se. A check is done to make sure the syntax is respected.
  • Fully validating the mimetype would required IMHO a class or a lib on its own.

@smuriu
Copy link

smuriu commented Sep 30, 2015

Just a thought, could be enhanced with an extra dependency on one of the many available mime type libraries (or a league one) and the validation would basically examine the detected mime to determine if it is in one of those specified in the mime library. Optionally, this could be extended with application-specific mime types. Have only had a cursory glance at some of the existing mime type libraries, but I imagine what I described may very well be within their scope. What do you think?

@nyamsprod
Copy link
Member Author

I though about it but again I try to check for a good mimetype validation library in PHP and I found none. Maybe I've missed it. Anyway the main problem is how do you enforce or validate a mimetype in the first place ?

As of now in the current library:

  • The mimetype is correct if you use the createFromPath method as this method uses internally PHP's finfo class.
  • The mimetype is semantically correct and no more when you use the constructor since there's no way to fully validate the mimetype.

Validating mimetype is really tricky as you need to conform to the mediatype RFCs (define in the Data URI and the email RFC) and to IANA repository of mimetype. And you also need to take into account proprietary mimetypes. It's not that simple. That's why I think fully validating mimetype in this package is out of scope.

nyamsprod added a commit that referenced this pull request Oct 6, 2015
@nyamsprod nyamsprod merged commit 7586ffd into master Oct 6, 2015
@nyamsprod nyamsprod deleted the bugfix/mimetype branch October 7, 2015 09:47
nyamsprod added a commit that referenced this pull request Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants