File tree Expand file tree Collapse file tree
core/src/main/java/com/ocpsoft/pretty
tests-jsf2/src/test/java/com/ocpsoft/pretty/faces/test/encoding Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -190,10 +190,12 @@ else if (queryString == null)
190190 else if ((ruleUrl != null ) && !"" .equals (ruleUrl .trim ()))
191191 {
192192 /*
193- * This is a custom location - don't URLEncode, just
194- * redirect
193+ * This is a custom location - don't call encodeRedirectURL(),
194+ * just redirect to the encoded URL
195195 */
196- resp .setHeader ("Location" , newUrl );
196+ URL encodedNewUrl = new URL (newUrl ).encode ();
197+ String location = req .getContextPath () + encodedNewUrl .toURL ();
198+ resp .setHeader ("Location" , location );
197199 resp .setStatus (rule .getRedirect ().getStatus ());
198200 resp .setCharacterEncoding (url .getEncoding ());
199201 resp .flushBuffer ();
Original file line number Diff line number Diff line change @@ -59,19 +59,19 @@ public void testRewriteEncoding() throws Exception
5959 {
6060 String target = "/virtual" ;
6161 String expected = "/virtuální" ;
62- //
63- // JSFSession jsfSession = new JSFSession(target);
64- // JSFServerSession server = jsfSession.getJSFServerSession();
65- //
66- // JSFClientSession client = jsfSession.getJSFClientSession();
67- // String action = client.getElement("form").getAttribute("action");
68- //
69- // FacesContext context = server.getFacesContext();
70- // PrettyContext prettyContext =
71- // PrettyContext.getCurrentInstance(context);
72- //
73- // assertEquals(expected, prettyContext.getRequestURL().toString());
74- // assertEquals(prettyContext.getContextPath() + expected, action);
62+
63+ JSFSession jsfSession = new JSFSession (target );
64+ JSFServerSession server = jsfSession .getJSFServerSession ();
65+
66+ JSFClientSession client = jsfSession .getJSFClientSession ();
67+ String action = client .getElement ("form" ).getAttribute ("action" );
68+
69+ FacesContext context = server .getFacesContext ();
70+ PrettyContext prettyContext =
71+ PrettyContext .getCurrentInstance (context );
72+
73+ assertEquals (expected , prettyContext .getRequestURL ().toString ());
74+ assertEquals (prettyContext .getContextPath () + expected , action );
7575 }
7676
7777 @ Test
You can’t perform that action at this time.
0 commit comments