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

Escape for slashes in path #414

Closed
danroot opened this issue May 27, 2016 · 3 comments
Closed

Escape for slashes in path #414

danroot opened this issue May 27, 2016 · 3 comments
Assignees
Milestone

Comments

@danroot
Copy link

danroot commented May 27, 2016

With a path such as this: /service/Users('Some%5Cuser') a 404 is always returned. What is the best way to fix this or override the issue within Restier?

Assemblies affected

RESTier 0.4.0-rc2

Reproduce steps

Build a service on a EF context with a table with string key
Ensure a record with key 'Some\user'
browse to /service/Users('Some%5Cuser')

Expected result

Expect a return value.

Actual result

404

Additional details

This is due to a "by design" behavior of Web API OData. An explanation and a workaround is provided in this sample:
https://github.com/OData/ODataSamples/tree/master/WebApi/v4/ODataPathAndSlashEscapeSample

However, I'm unclear how to implement this in Restier.

@chinadragon0515
Copy link
Contributor

@danroot we have not exposed IPahHandler as DI service in RESTier yet, the workaround is not simple as we do in Web Api now.

To workaround this one,

  1. Create a class similar to https://github.com/OData/ODataSamples/blob/master/WebApi/v4/ODataPathAndSlashEscapeSample/ProductODataService/Extensions/PathAndSlashEscapeODataPathHandler.cs
  2. In your WebApiConfig.cs file, copy methods from https://github.com/OData/RESTier/blob/master/src/Microsoft.Restier.Publishers.OData/Routing/HttpConfigurationExtensions.cs), and replace "new DefaultODataPathHandler()" with "new CustomizedODataPathHandler()".

Let me know if you have more questions, in the meanwhile, I create #415 to make this replacement same as other service, and will be delivered in next release.

@chinadragon0515
Copy link
Contributor

This sample does not work, stay tuned.
I am working on some workable solution now, both temp solution and fix in code.

@chinadragon0515
Copy link
Contributor

Per comments from web api team, IIS will escape back slash and this is not configurable.

A temp solution with end to end test case is added with #415, refer to it for detail on how to enable , but back slash and slash is not recommended used in the key as Web API suggests, as there may become a security hole.

Also for permanent solution, it is tracked with #421 , key value will be as query options and refer to URL via key alias.

I close this issue now, any questions or comments, let us know.

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

No branches or pull requests

2 participants