@@ -61,22 +61,18 @@ public boolean redirect(final FacesContext context, final String action)
6161
6262 String target = contextPath + url .encode () + query .toQueryString ();
6363 log .trace ("Refreshing requested page [" + url + "]" );
64- String redirectUrl = externalContext .encodeActionURL (target );
65- redirectUrl = ((HttpServletResponse ) externalContext .getResponse ()).encodeRedirectURL (redirectUrl );
66- externalContext .redirect (redirectUrl );
64+ encodeURL (externalContext , config , target );
6765 return true ;
6866 }
6967 else if (isPrettyNavigationCase (prettyContext , action ))
7068 {
7169 UrlMapping mapping = config .getMappingById (action );
7270 if (mapping != null )
7371 {
74- String url = contextPath + builder .buildURL (mapping ).encode ()
72+ String target = contextPath + builder .buildURL (mapping ).encode ()
7573 + builder .buildQueryString (mapping );
76- log .trace ("Redirecting to mappingId [" + mapping .getId () + "], [" + url + "]" );
77- String redirectUrl = externalContext .encodeActionURL (url );
78- redirectUrl = ((HttpServletResponse ) externalContext .getResponse ()).encodeRedirectURL (redirectUrl );
79- externalContext .redirect (redirectUrl );
74+ log .trace ("Redirecting to mappingId [" + mapping .getId () + "], [" + target + "]" );
75+ encodeURL (externalContext , config , target );
8076 }
8177 else
8278 {
@@ -92,6 +88,20 @@ else if (isPrettyNavigationCase(prettyContext, action))
9288 return false ;
9389 }
9490
91+ private void encodeURL (ExternalContext externalContext , PrettyConfig config , String target ) throws IOException
92+ {
93+ String redirectUrl = externalContext .encodeActionURL (target );
94+ if (config .isUseEncodeUrlForRedirects ())
95+ {
96+ redirectUrl = ((HttpServletResponse ) externalContext .getResponse ()).encodeURL (redirectUrl );
97+ }
98+ else
99+ {
100+ redirectUrl = ((HttpServletResponse ) externalContext .getResponse ()).encodeRedirectURL (redirectUrl );
101+ }
102+ externalContext .redirect (redirectUrl );
103+ }
104+
95105 public void send404 (final FacesContext facesContext )
96106 {
97107 try
0 commit comments