@@ -59,22 +59,18 @@ public boolean redirect(final FacesContext context, final String action)
5959
6060 String target = contextPath + url .encode () + query .toQueryString ();
6161 log .trace ("Refreshing requested page [" + url + "]" );
62- String redirectUrl = externalContext .encodeActionURL (target );
63- redirectUrl = ((HttpServletResponse ) externalContext .getResponse ()).encodeRedirectURL (redirectUrl );
64- externalContext .redirect (redirectUrl );
62+ encodeURL (externalContext , config , target );
6563 return true ;
6664 }
6765 else if (isPrettyNavigationCase (prettyContext , action ))
6866 {
6967 UrlMapping mapping = config .getMappingById (action );
7068 if (mapping != null )
7169 {
72- String url = contextPath + builder .buildURL (mapping ).encode ()
70+ String target = contextPath + builder .buildURL (mapping ).encode ()
7371 + builder .buildQueryString (mapping );
74- log .trace ("Redirecting to mappingId [" + mapping .getId () + "], [" + url + "]" );
75- String redirectUrl = externalContext .encodeActionURL (url );
76- redirectUrl = ((HttpServletResponse ) externalContext .getResponse ()).encodeRedirectURL (redirectUrl );
77- externalContext .redirect (redirectUrl );
72+ log .trace ("Redirecting to mappingId [" + mapping .getId () + "], [" + target + "]" );
73+ encodeURL (externalContext , config , target );
7874 }
7975 else
8076 {
@@ -90,6 +86,20 @@ else if (isPrettyNavigationCase(prettyContext, action))
9086 return false ;
9187 }
9288
89+ private void encodeURL (ExternalContext externalContext , PrettyConfig config , String target ) throws IOException
90+ {
91+ String redirectUrl = externalContext .encodeActionURL (target );
92+ if (config .isUseEncodeUrlForRedirects ())
93+ {
94+ redirectUrl = ((HttpServletResponse ) externalContext .getResponse ()).encodeURL (redirectUrl );
95+ }
96+ else
97+ {
98+ redirectUrl = ((HttpServletResponse ) externalContext .getResponse ()).encodeRedirectURL (redirectUrl );
99+ }
100+ externalContext .redirect (redirectUrl );
101+ }
102+
93103 public void send404 (final FacesContext facesContext )
94104 {
95105 try
0 commit comments