Skip to content

[CXF-8353] MediaType validation#707

Merged
andymc12 merged 2 commits intoapache:masterfrom
andymc12:invalidMediaTypeCheck
Oct 12, 2020
Merged

[CXF-8353] MediaType validation#707
andymc12 merged 2 commits intoapache:masterfrom
andymc12:invalidMediaTypeCheck

Conversation

@andymc12
Copy link
Contributor

@andymc12 andymc12 commented Oct 6, 2020

Performs validation on the type and subtype of the MediaType string passed-in according to https://tools.ietf.org/html/rfc2045#section-5.1

@andymc12 andymc12 requested a review from reta October 6, 2020 21:10
@andymc12 andymc12 self-assigned this Oct 6, 2020
// Determines whether the type or subtype contains any of the tspecials characters defined at:
// https://tools.ietf.org/html/rfc2045#section-5.1
private static boolean isValid(String str) {
final int len = str.length();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, may be check str.trim().length(), it seems weird media types like application/ are still passing through.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reta - sounds good. Since we end up trimming both type and subType at lines 114 and 115, I moved those trims to before the isValid method is called (to lines 88 and 89). Let me know if you'd prefer the trim to be in isValid instead. Otherwise, I'll plan to merge this later today. Thanks for the review!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks @andymc12 !

Signed-off-by: Andy McCright <j.andrew.mccright@gmail.com>
Signed-off-by: Andy McCright <j.andrew.mccright@gmail.com>
@andymc12 andymc12 force-pushed the invalidMediaTypeCheck branch from e1280ff to e0c1b36 Compare October 12, 2020 14:08
@andymc12 andymc12 merged commit ef6db60 into apache:master Oct 12, 2020
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