Skip to content

AbstractUriBuilder.ArrayVariableResolver does not encode reserved character [ (char 91) in path #601

Closed
@jamiemaher

Description

@jamiemaher

In jaxrs-2.0.11 when building a URI path with UriBuilder.build(Object... values) reserved characters in the path are not replaced with the url encoded version.

For example the UriBuilder is constructed like this:

UriBuilder.fromUri(urlApiEntryPoint).path( Class ).build(var1,var2,var3)

which works fine, until var3 contains something like "file[rw].jpg"

When the ArrayVariableResolver attempts to resolve the variable for the ending portion of the URI it encodes the value using:
EncodeOrCheck.all(varValue, this.encoding) at line 103 of AbstractUriBuilder, and during the all() method it simply checks the validity of the character using Reference.isValid(c), but does not check if the character is a valid in the path portion of the uri:

EncodeOrCheck line 103

            final char c = string.charAt(i);
            if (c == '%') {
                processPercent(i, encode, string, stb);
            } else if (Reference.isValid(c)) {
                stb.append(c);
            } else {
                toHexOrReject(c, stb, encode);
            }

"[" (or char 91) is a valid character because it is allowed to surround the host to denote a ip6 address, but I don't believe it should be allowed in the path at all?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions