1

My REST resource (using Jersey) receive IPv6 address using QueryParam.

When the address value received in the resource, some of its characters are encoded, don't know with which algorithm.

For example, the address: [fe80::bce8:a33e:2c56:d48a%13]
Arrives like this:
In debug it looks like [fe80::bce8:a33e:2c56:d48a\u00]
But when priting it out: [fe80::bce8:a33e:2c56:d48a]

I understand that '\u00' is translated to white space, but why does this happened? How can I overcome this? Is there a way to decode it?

Thanks

2
  • The scope identifier should not be sent in the request, it has only logical meaning to the client host: which adapter to use. The request thus should only contain the address: [fe80::bce8:a33e:2c56:d48a]
    – Steve-o
    Jan 28, 2013 at 16:29
  • Hi, this is how our logic is working. The client knows the entire IP and cannot parse it.
    – danieln
    Jan 29, 2013 at 10:33

3 Answers 3

1

As per RFC2396:

  Because the percent "%" character always has the reserved purpose of
  being the escape indicator, it must be escaped as "%25" in order to
  be used as data within a URI.

It is not possible for Jersey to understand whether this is a reserved character or not. So, in your case I believe you should escape the reserved character in your query param, then it should work as expected:

[fe80::bce8:a33e:2c56:d48a%2513]
1
  • You are right. Our clients escaped the parameter and now it's working.
    – danieln
    Jan 29, 2013 at 10:32
0

IPv6 addresses consist of eight 4-digit hex characters with seven : separators

hence you need to convert the hex characters to integers independently.

2
  • I'm not sure what you are saying. Where should I convert them? in the REST resource? How can I convert them if I'm getting the value decoded?
    – danieln
    Jan 28, 2013 at 8:30
  • I can't convert it because it comes malformed, as you can see in my question.
    – danieln
    Jan 28, 2013 at 8:37
0

One of the causes seems to be that you use link-local addresses (those starting with fe80:). Because every link has those addresses the address needs to include a specification of which link you mean. That is the %13 part you see. If the string is parsed as a URL encoded string then %13 will become the DC3 control code (which has hexadecimal number 0x13).

I don't know QueryParam, but this seems a bug. IP addresses aren't URL-encoded so it shouldn't try to decode them...

1
  • And the % followed by an interface id is perfectly normal Jan 28, 2013 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.