Skip to content

Use play.utils.UriEncoding.encodePathSegment to encode path segments.#122

Merged
mbryzek merged 1 commit intoapicollective:masterfrom
fiadliel:wip/path-encode
Aug 5, 2014
Merged

Use play.utils.UriEncoding.encodePathSegment to encode path segments.#122
mbryzek merged 1 commit intoapicollective:masterfrom
fiadliel:wip/path-encode

Conversation

@fiadliel
Copy link
Contributor

@fiadliel fiadliel commented Aug 5, 2014

java.net.URLEncoder.encode does not encode path parameters correctly, while
it is (mostly) sufficient for query parameters. Use a Play API call which
tries to do the right thing, see the API at
http://www.playframework.com/documentation/2.3.x/api/scala/index.html#play.utils.UriEncoding$

Path segment encoding differs from encoding for other parts of a URI. For
example, the "&" character is permitted in a path segment, but has special
meaning in query parameters. On the other hand, the "/" character cannot appear
in a path segment, as it is the path delimiter, so it must be encoded as "%2F".
These are just two examples of the differences between path segment and query
string encoding; there are other differences too.

java.net.URLEncoder.encode does not encode path parameters correctly, while
it is (mostly) sufficient for query parameters. Use a Play API call which
tries to do the right thing, see the API at
http://www.playframework.com/documentation/2.3.x/api/scala/index.html#play.utils.UriEncoding

Path segment encoding differs from encoding for other parts of a URI. For
example, the "&" character is permitted in a path segment, but has special
meaning in query parameters. On the other hand, the "/" character cannot appear
in a path segment, as it is the path delimiter, so it must be encoded as "%2F".
These are just two examples of the differences between path segment and query
string encoding; there are other differences too.
@mbryzek
Copy link
Collaborator

mbryzek commented Aug 5, 2014

+2

mbryzek added a commit that referenced this pull request Aug 5, 2014
Use play.utils.UriEncoding.encodePathSegment to encode path segments.
@mbryzek mbryzek merged commit 1d2a971 into apicollective:master Aug 5, 2014
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