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

fix: strip parameters from data content types to assess if it's JSON format #484

Conversation

fredoboulo
Copy link
Contributor

@fredoboulo fredoboulo commented Oct 3, 2022

Fixes #481

Signed-off-by: Frederic Delechamp fdelechamp@guidewire.com

@fredoboulo
Copy link
Contributor Author

Fixes #481

@pierDipi pierDipi changed the title fix: strip parameters from data content types to assess if it's JSON … fix: strip parameters from data content types to assess if it's JSON format Oct 3, 2022
@JemDay
Copy link
Contributor

JemDay commented Oct 3, 2022

** 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.

@fredoboulo fredoboulo force-pushed the user/fdelechamp/Issue-481-json-deserialization branch from 5a1c42d to 00a37de Compare October 4, 2022 07:24
@fredoboulo
Copy link
Contributor Author

@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.

JemDay
JemDay previously approved these changes Oct 4, 2022
Copy link
Contributor

@JemDay JemDay left a 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\"!#$%&'*+.^_`{|}~=-]*)*$");
Copy link
Contributor

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. ;-)

Copy link
Contributor Author

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 <fdelechamp@guidewire.com>
@fredoboulo fredoboulo force-pushed the user/fdelechamp/Issue-481-json-deserialization branch from 4d42d08 to 04fd4b8 Compare October 5, 2022 05:42
Copy link
Contributor

@JemDay JemDay left a comment

Choose a reason for hiding this comment

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

Thanks ...

Copy link
Member

@pierDipi pierDipi left a comment

Choose a reason for hiding this comment

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

LGTM

@pierDipi
Copy link
Member

pierDipi commented Oct 6, 2022

Thanks @fredoboulo!

@pierDipi pierDipi merged commit 6362bfb into cloudevents:master Oct 6, 2022
@pierDipi
Copy link
Member

pierDipi commented Oct 6, 2022

@fredoboulo would you be willing to backport the merged commit 6362bfb to the 2.4 branch for a patch release?

@fredoboulo
Copy link
Contributor Author

Hi @pierDipi, that's about cherry-picking and making a PR in branch 2.4?

fredoboulo added a commit to fredoboulo/cloudevents-sdk-java that referenced this pull request Oct 12, 2022
cloudevents#484)

Signed-off-by: Frederic Delechamp <fdelechamp@guidewire.com>
pierDipi pushed a commit that referenced this pull request Oct 12, 2022
#484) (#485)

Signed-off-by: Frederic Delechamp <fdelechamp@guidewire.com>
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.4.0 breaks JSON Deserialization
4 participants