0

When handling urls of the syntax

http://foo.com?bar=%test%

jetty throws an IllegalArgumentException saying its not a valid hex value.

We tried to change the character encoding to UTF-16 but that still does not parse %. Is there a way to allow '%' to be parsed by getParameter or getParameterMap function in HttpPServletRequest interface?

Expected output for the getParameter("bar") = "%test%"

Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
ansh2201
  • 11
  • 2
  • 5
  • "%" is a key word for URI, and the jetty will get parsing exception when you request "bar=%test%" due to http protocol. as i know, the "%" equals to "%25",so you can request "http://foo.com?bar=%25test%25" to achieve it. – CHmoonKa Oct 23 '14 at 04:46

1 Answers1

0

The symbol % in a URL/URI is a reserved character for processing Percent Encoded characters in a URL/URI. - see RFC3986 Section 2.1

What Jetty saw is the % character, and then has to use the next 2 characters te to decode which UTF-8 byte you are wanting, which in your test case results in an invalid percent encoding.

At its most fundamental, your example URL/URI is a "Malformed URI". (try to decode it in Javascript or Python or Perl)

Also Note, all URL/URI processing is effectively UTF-8 (it is standard and spec breaking to parse a URL/URI in a different encoding scheme)

Community
  • 1
  • 1
Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136