Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

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

kirank84421130
Level 1
Level 1

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

1 Accepted Solution
Theo_Pendle
Correct answer by
Community Advisor
Community Advisor

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():

Peek 2020-03-26 17-54.gif

 

View solution in original post

3 Replies
Theo_Pendle
Correct answer by
Community Advisor
Community Advisor

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():

Peek 2020-03-26 17-54.gif

 

View solution in original post

Jörg_Hoh
Employee
Employee

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?