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

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

Avatar

Avatar
Give Back
Level 1
kirank84421130
Level 1

Likes

0 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Give Back
View profile

Avatar
Give Back
Level 1
kirank84421130
Level 1

Likes

0 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Give Back
View profile
kirank84421130
Level 1

26-03-2020

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
MVP
Theo_Pendle
MVP

Likes

236 likes

Total Posts

251 posts

Correct Reply

105 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile

Avatar
Validate 1
MVP
Theo_Pendle
MVP

Likes

236 likes

Total Posts

251 posts

Correct Reply

105 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile
Theo_Pendle
MVP

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

Peek 2020-03-26 17-54.gif

 

Answers (1)

Answers (1)

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,081 likes

Total Posts

3,121 posts

Correct Reply

1,061 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,081 likes

Total Posts

3,121 posts

Correct Reply

1,061 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

30-03-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?