-
Notifications
You must be signed in to change notification settings - Fork 160
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
fix: strip parameters from data content types to assess if it's JSON format #484
fix: strip parameters from data content types to assess if it's JSON format #484
Conversation
Fixes #481 |
** This may apply to much more than just the JSON format serialization. Don't the various transport bindings also check for content-type such as application/cloudevents+json ?? theoretically those checks should also include this type of stripping. I'm not sure if now is the time but we may want to break all of this stuff out into a some core utilities that can be shared across all of the formats and transports .. most specifically "take a content-type and strip off all the trailing attributes" and "isJson(stripped-content-type)" type functions. Not sure if we should address this now or add it as a followup .. it might need a bit more analysis to see where everybody is doing a comparison on content-type. |
5a1c42d
to
00a37de
Compare
@JemDay I'm not sure this comment is directed to me but... it makes sense to me, for the potential to be needed elsewhere. However, I'm not familiar with this particular project, so I'd individually prefer to defer refactoring in a different context than this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM .. simplifying the regex would be nice for efficient processing but could be a follow-on activity.
@@ -47,7 +47,7 @@ public final class JsonFormat implements EventFormat { | |||
/** | |||
* JSON Data Content Type Discriminator | |||
*/ | |||
private static final Pattern JSON_CONTENT_TYPE_PATTERN = Pattern.compile("^(application|text)\\/([a-zA-Z]+\\+)?json$"); | |||
private static final Pattern JSON_CONTENT_TYPE_PATTERN = Pattern.compile("^(application|text)\\/([a-zA-Z]+\\+)?json(;[\\s\\w\"!#$%&'*+.^_`{|}~=-]*)*$"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this regex can be simplified so that it simply matches anything following the ";" so something like "(;.*)*$"
- my regex may be a bit rusty. ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I was overdoing it :)
…format Signed-off-by: Frederic Delechamp <[email protected]>
4d42d08
to
04fd4b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @fredoboulo! |
@fredoboulo would you be willing to backport the merged commit 6362bfb to the 2.4 branch for a patch release? |
Hi @pierDipi, that's about cherry-picking and making a PR in branch 2.4? |
cloudevents#484) Signed-off-by: Frederic Delechamp <[email protected]>
#484) (#485) Signed-off-by: Frederic Delechamp <[email protected]>
Fixes #481
Signed-off-by: Frederic Delechamp [email protected]