-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Support unencoded reserved characters in path segments #1319
Comments
@OlgaMaciaszek I agree our handling of this continues to be poor. We intentionally removed the I've been leaning on support all 4 levels of expressions as the solution. Doing so would allow for programmatic assignment of the expression level, as in your use case, and direct usage of the specs template layouts. I'm planning on starting this in earnest very soon, but I don't want to block your issue. What I think we can do in the meantime is add support for path style expressions first and release that asap. That should open up support and then you can refactor your processor to instead of registering a custom expander, just manipulate the template, ensuring that any values annotated with |
@OlgaMaciaszek could you please respond to this? @nickcodefresh and I are both keen to get the issue that's affecting us resolved (as per the linked ticket.) |
@kdavisk6 , @oliverlockwood Sorry for not getting back to you earlier. Have taken some time off after the holidays.
@kdavisk6 if it's going to allow us to set the encoding not to include the |
ping @kdavisk6 ? |
Any update on this @OlgaMaciaszek @kdavisk6 ? |
+1 - I'm trying to use OpenFeign for a REST client in a different project (not related in any way to Spring Cloud OpenFeign), but hit a brick wall trying to support matrix parameters. Is there any active discussion on this topic outside of this ticket? |
@kdavisk6 @OlgaMaciaszek @velo this has now been open for 4 months without real activity - is there any chance we could have some input, please? I'm happy to do some coding and contribute if you're able to point me in the right general direction and your preferred approach; what I really don't want to end up doing is maintaining a fork of this project. We have been blocked on upgrading Spring-Cloud for some time as a result of this issue, and that now blocks us from upgrading Spring-Boot, so it's pretty critical to us now. |
All, thank you for your patience. I understand the issue and it's importance to you all. The root of the issue is that our URI template expression handling is very simple and limited. I have an idea where we can move expansion of custom expanders deeper into the parsing. This would require expanders to manage pct-encoding directly however, which may break existing integrations. I'd like more time to think it through. |
Hi @kdavisk6, has there been any progress regarding this issue? |
This is my fault. I will pick this up this week. |
@kdavisk6 is there anything @nickcodefresh or I could do to assist you / test / etc? |
Fixes OpenFeign#1319 This change adds limited Path Style support to Feign URI template-style templates. Variable expressions that start with a semi-colon `;` are now expanded in accordance to [RFC 6570 Section 3.2.7](https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.7) with the following modifications: * Maps and Lists are expanded by default. * Only Single variable templates are supported. Examples: ``` {;who} ;who=fred {;half} ;half=50%25 {;empty} ;empty {;list} ;list=red;list=green;list=blue {;keys} ;semi=%3B;dot=.;comma=%2C ```
@OlgaMaciaszek @oliverlockwood I've added #1537 to enable support for Path Style parameters. Expressions that start with semi-colons Examples
You no longer need a custom expander for this type of expression, as this change exposes For example, in @Override
public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) {
int parameterIndex = context.getParameterIndex();
Class<?> parameterType = method.getParameterTypes()[parameterIndex];
MethodMetadata data = context.getMethodMetadata();
String name = ANNOTATION.cast(annotation).value();
checkState(emptyToNull(name) != null, "MatrixVariable annotation was empty on param %s.",
context.getParameterIndex());
context.setParameterName(name);
data.indexToExpander().put(parameterIndex, new PathStyleExpression(name, null);
return true;
} If this meets your needs, please let me know and we'll work on getting it released. |
Fixes OpenFeign#1319 This change adds limited Path Style support to Feign URI template-style templates. Variable expressions that start with a semi-colon `;` are now expanded in accordance to [RFC 6570 Section 3.2.7](https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.7) with the following modifications: * Maps and Lists are expanded by default. * Only Single variable templates are supported. Examples: ``` {;who} ;who=fred {;half} ;half=50%25 {;empty} ;empty {;list} ;list=red;list=green;list=blue {;keys} ;semi=%3B;dot=.;comma=%2C ```
* [GH-1319] Add Support for Path Style Parameter Expansion Fixes #1319 This change adds limited Path Style support to Feign URI template-style templates. Variable expressions that start with a semi-colon `;` are now expanded in accordance to [RFC 6570 Section 3.2.7](https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.7) with the following modifications: * Maps and Lists are expanded by default. * Only Single variable templates are supported. Examples: ``` {;who} ;who=fred {;half} ;half=50%25 {;empty} ;empty {;list} ;list=red;list=green;list=blue {;keys} ;semi=%3B;dot=.;comma=%2C ``` * Export Path Style Expression as an Expander for use with custom contracts * Added example to ReadMe * Additional Test Cases.
* [GH-1319] Add Support for Path Style Parameter Expansion Fixes #1319 This change adds limited Path Style support to Feign URI template-style templates. Variable expressions that start with a semi-colon `;` are now expanded in accordance to [RFC 6570 Section 3.2.7](https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.7) with the following modifications: * Maps and Lists are expanded by default. * Only Single variable templates are supported. Examples: ``` {;who} ;who=fred {;half} ;half=50%25 {;empty} ;empty {;list} ;list=red;list=green;list=blue {;keys} ;semi=%3B;dot=.;comma=%2C ``` * Export Path Style Expression as an Expander for use with custom contracts * Added example to ReadMe * Additional Test Cases.
* [GH-1319] Add Support for Path Style Parameter Expansion Fixes #1319 This change adds limited Path Style support to Feign URI template-style templates. Variable expressions that start with a semi-colon `;` are now expanded in accordance to [RFC 6570 Section 3.2.7](https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.7) with the following modifications: * Maps and Lists are expanded by default. * Only Single variable templates are supported. Examples: ``` {;who} ;who=fred {;half} ;half=50%25 {;empty} ;empty {;list} ;list=red;list=green;list=blue {;keys} ;semi=%3B;dot=.;comma=%2C ``` * Export Path Style Expression as an Expander for use with custom contracts * Added example to ReadMe * Additional Test Cases.
Some time ago, we had support for MatrixVariables added to Spring Cloud OpenFeign, using this processor.
This implementation works ok while sending requests to Spring REST controllers that can handle incorrectly encoded
;
and=
characters for matrix variables. However, an issue has been reported here that causes problems for servers that will not handle incorrect encoding of matrix variable reserved characters.Basically, since matrix variables can appear in any path segment, they are handled by us as path params, with values stored in
indexToExpander
and get fully pct-encoded by feign-core, including their special characters, so we get/server/matrixParams%3Baccount%3Da%3Bname%3D
instead of/server/matrixParams;account=a;name=n
.It looks like an issue that can only be addressed within feign-core and not as part of our integration. I could work on a fix if that's fine with you. An idea that comes to mind is to introduce some kind of markers, say
{{}}
that would surround characters that should not be encoded within expanded path param chunks, but I'm also open to work on any other solution that the team might prefer. Let me know what you think about it.The text was updated successfully, but these errors were encountered: