Skip to main content
Level 2
March 26, 2020
Solved

Please help me to fix this error "java.lang.IllegalArgumentException: Bad escape sequence: %"

When I check the error log for one instance it is throwing Bad escape sequence. Please help me to fix this

ERROR* [qtp1968936611-3259627] org.apache.sling.engine.impl.parameters.ParameterSupport getRequestParameterMapInternal: Error parsing request java.lang.IllegalArgumentException: Bad escape sequence: %3Q at org.apache.sling.engine.impl.parameters.Util.parseNVPairString(Util.java:330) [org.apache.sling.engine:2.6.12] at org.apache.sling.engine.impl.parameters.Util.parseQueryString(Util.java:215) [org.apache.sling.engine:2.6.12] at org.apache.sling.engine.impl.parameters.ParameterSupport.getRequestParameterMapInternal(ParameterSupport.java:256) [org.apache.sling.engine:2.6.12] at org.apache.sling.engine.impl.parameters.ParameterSupport.getParameter(ParameterSupport.java:179) [org.apache.sling.engine:2.6.12] at org.apache.sling.engine.impl.parameters.ParameterSupportHttpServletRequestWrapper.getParameter(ParameterSupportHttpServletRequestWrapper.java:40) [org.apache.sling.engine:2.6.12] at com.day.crx.security.token.TokenCookie.fromRequest(TokenCookie.java:98) [com.day.crx.sling.crx-auth-token:2.5.36] at com.day.crx.security.token.TokenCookie.getTokenInfo(TokenCookie.java:137) [com.day.crx.sling.crx-auth-token:2.5.36] at com.day.crx.security.token.impl.TokenAuthenticationHandler.extractCredentials(TokenAuthenticationHandler.java:490) [com.day.crx.sling.crx-auth-token:2.5.36] at org.apache.sling.auth.core.impl.AuthenticationHandlerHolder.doExtractCredentials(AuthenticationHandlerHolder.java:76) [org.apache.sling.auth.core:1.4.2] at org.apache.sling.auth.core.impl.AbstractAuthenticationHandlerHolder.extractCredentials(AbstractAuthenticationHandlerHolder.java:60) [org.apache.sling.auth.core:1.4.2] at org.apache.sling.auth.core.impl.SlingAuthenticator.getAuthenticationInfo(SlingAuthenticator.java:735) [org.apache.sling.auth.core:1.4.2] at org.apache.sling.auth.core.impl.SlingAuthenticator.doHandleSecurity(SlingAuthenticator.java:483) [org.apache.sling.auth.core:1.4.2] at org.apache.sling.auth.core.impl.SlingAuthenticator.handleSecurity(SlingAuthenticator.java:460) [org.apache.sling.auth.core:1.4.2] at org.apache.sling.engine.impl.SlingHttpContext.handleSecurity(SlingHttpContext.java:131) [org.apache.sling.engine:2.6.12]

 

What was the approach to escape the % character in the URL

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Theo_Pendle
Theo_PendleAccepted solution
Level 8
March 26, 2020

Hello 🙂

 

So if I understand correctly, you are trying to visit a URL with a '%' character in it and it is causing issues?

 

If you want to escape the '%' character you should use the following: '%25'. SO for example:

'www.example.com?percentage=25%'

becomes:

"www.example.com%3Fpercentage%3D25%25"

 

You can test this easily by opening your browser console (right here on this page if you want) by hitting F12 and then using the following native function: encodeURIComponent():

 

3 replies

Theo_Pendle
Theo_PendleAccepted solution
Level 8
March 26, 2020

Hello 🙂

 

So if I understand correctly, you are trying to visit a URL with a '%' character in it and it is causing issues?

 

If you want to escape the '%' character you should use the following: '%25'. SO for example:

'www.example.com?percentage=25%'

becomes:

"www.example.com%3Fpercentage%3D25%25"

 

You can test this easily by opening your browser console (right here on this page if you want) by hitting F12 and then using the following native function: encodeURIComponent():

 

Translate
kautuk_sahni
Adobe Employee
Adobe Employee
June 25, 2020
Very well answered.
Translate
Kautuk Sahni
joerghoh
Adobe Employee
Adobe Employee
March 30, 2020

It looks that your URL is incorrect: "Bad escape sequence: %3Q" means that there is a sequence "%3Q" which is considered as an URL escaped sequence, but it's not valid.

 

Can you post the complete URL (at least the part after the pagename)? How is this URL created?

Translate