Skip to content

Commit f2c2bc6

Browse files
committed
Fixed encoding and decording of vertical bar (|) character
1 parent a2b7279 commit f2c2bc6

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎CHANGELOG.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Bugfixes:
1313
* Empty segments are now handled correctly - thanks to Piotr Jastrzebski for the patch (#123)
1414
* Fixed encoding for square brackets and less/greater than characters
1515
* Don't apply rewrite rule to requests forwarded by URL-mappings anymore
16+
* Fixed encoding/decoding of vertical bar (|) character
1617

1718
------------------------------------
1819
VERSION 3.3.2

‎core/src/main/java/com/ocpsoft/pretty/faces/url/URL.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ private static String decodeSegment(final String segment)
152152
.replace("]", "%5D")
153153
.replace("<", "%3C")
154154
.replace(">", "%3E")
155+
.replace("|", "%7C")
155156
);
156157
return uri.getPath().substring(1);
157158
}

‎core/src/test/java/com/ocpsoft/pretty/faces/url/URLTest.java‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,21 @@ public void testLessGreaterThanEncodingAndDecoding() throws Exception
188188
assertEquals("/<a>", new URL("/<a>").decode().toURL());
189189

190190
}
191-
191+
192+
@Test
193+
public void testPipeEncodingAndDecoding() throws Exception
194+
{
195+
196+
// encode
197+
assertEquals("/%7C", new URL("/|").encode().toURL());
198+
199+
// decode
200+
assertEquals("/|", new URL("/%7C").decode().toURL());
201+
202+
// decode of not-encoded character
203+
assertEquals("/|", new URL("/|").decode().toURL());
204+
205+
}
206+
207+
192208
}

0 commit comments

Comments
 (0)