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

no allowable_content_types for description (avoid validation) #63

Merged
merged 2 commits into from
Sep 22, 2016

Conversation

tschorr
Copy link
Contributor

@tschorr tschorr commented Sep 20, 2016

Product.Archetypes.Field.validate invokes validate_content_types if allowable_content_types is set on a field. In case of the description field, this can lead to surprising validation results because the method is trying to guess the content type using the mimetypes_registry. Example: If you enter the word 'Stammdaten' (german for master data) as the first word into a description field, you see a validation error telling you that the MIME type 'video/quicktime' is not allowed for the field. This is because the mimetypes_registry is trying to guess the MIME type of the string 'Stammdaten' using a test in Products.MimetypesRegistry.mime_types.magic. The term 'Stammdaten' matches the following test pattern:

[4, 'string', '=', 'mdat', 'video/quicktime']

(letters 'mdat' starting at position4)

It is perfectly valid to have 'Stammdaten' as the first term in a german description, but Plone doesn't let you save this. Looking at the other test patterns there are potentially many more cases like this.

The testing procedure maybe could be improved (validating the content type is not about guessing the MIME type from the content but rather testing wether the content conforms to one of the allowable content types) but the suggestion is to simply drop the constraint on the description field since text/plain is the fallback.

@tschorr
Copy link
Contributor Author

tschorr commented Sep 20, 2016

I have already signed the Plone Contributors Agreement and just added the email used for this PR to my account.

@gforcada gforcada closed this Sep 20, 2016
@gforcada gforcada reopened this Sep 20, 2016
@gforcada
Copy link
Member

@tschorr welcome to plone then! The checks are already updated as well :-)

@jensens jensens merged commit 3ba7972 into 1.9.x Sep 22, 2016
@jensens jensens deleted the drop_allowable_content_types_from_description_pr branch September 22, 2016 21:19
@jensens
Copy link
Member

jensens commented Sep 22, 2016

@tschorr may you provide the same patch for master?

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.

4 participants