Jasper Floor pushed to branch master at cms-community / hippo-repository

Commits:
c8bb6f75 by Jeroen Hoffman at 2017-09-19T10:34:51+02:00
REPO-1822 in URI encoding, add support for special hyphens and quotes in the 
0x201x subrange of Unicode General Punctuation

- - - - -
79a1958b by Jasper Floor at 2017-09-20T13:26:39+02:00
REPO-1822 Merge master changes in feature/REPO-1822

- - - - -
cfbff022 by Jeroen Hoffman at 2017-09-21T09:48:19+02:00
REPO-1822 in URI encoding, treat quote-like characters as quote, so remove 
them, because quotes cannot be used in JCR node names

- - - - -
f4d0a989 by Jasper Floor at 2017-09-21T10:26:46+02:00
REPO-1822 Merge master changes in feature/REPO-1822

- - - - -
352aa381 by Jasper Floor at 2017-09-21T10:28:37+02:00
REPO-1822 Reintegrate feature/REPO-1822

- - - - -


2 changed files:

- api/src/main/java/org/hippoecm/repository/api/StringCodecFactory.java
- api/src/test/java/org/hippoecm/repository/api/UriEncodingTest.java


Changes:

=====================================
api/src/main/java/org/hippoecm/repository/api/StringCodecFactory.java
=====================================
--- a/api/src/main/java/org/hippoecm/repository/api/StringCodecFactory.java
+++ b/api/src/main/java/org/hippoecm/repository/api/StringCodecFactory.java
@@ -114,11 +114,14 @@ public class StringCodecFactory {
     }
 
     /**
-     * Direct usage of this class discouraged.  If should only be used by 
frameworks to initialize the StringCodecFactory instance.
-     * <p/>
-     * Performs a one-way encoding (no decoding possible) for translating any 
string to a suitable set of characters
-     * that can be used in URIs.
-     *
+     * The UriEncoding class is responsible for creating human-readable URI 
from a String, by either removing characters
+     * or by mapping them to characters that need not be percent-encoded.
+     * <p>
+     * Note that the name 'UriEncoding' is not fully accurate as it does not 
conform to URI specs but rather creates a
+     * slug, a human-readable String.
+     * </p><p>
+     * Direct usage of this class discouraged. It should only be used by 
frameworks to initialize the StringCodecFactory instance.
+     * </p>
      * @see <a href="doc-files/encoding.html">Encoding of node names</a>
      */
     public static class UriEncoding implements StringCodec {
@@ -513,6 +516,24 @@ public class StringCodecFactory {
                         case 0x017e: sb.append("z");    break; // ž
                         case 0x017f: sb.append("s");    break; // ſ
 
+                        // 0x201x subrange of Unicode General Punctuation, see 
https://en.wikipedia.org/wiki/General_Punctuation
+                        case 0x2010: sb.append("-");    break; // ‐ 
(hyphen-minus)
+                        case 0x2011: sb.append("-");    break; // ‑ 
(non-breaking hyphen)
+                        case 0x2012: sb.append("-");    break; // ‒
+                        case 0x2013: sb.append("-");    break; // –
+                        case 0x2014: sb.append("-");    break; // —
+                        case 0x2015: sb.append("-");    break; // ―
+                        case 0x2016: sb.append("-");    break; // ‖
+                        case 0x2017: sb.append("-");    break; // ‗
+                        case 0x2018: break; // ‘ (left single quotation) treat 
quote-like characters as quote: remove
+                        case 0x2019: break; // ’ (right single quotation)
+                        case 0x201a: break; // ‚
+                        case 0x201b: break; // ‛
+                        case 0x201c: break; // “
+                        case 0x201d: break; // ”
+                        case 0x201e: break; // „
+                        case 0x201f: break; // ‟
+
                         // 0xac00 - 0xd7a3 : Hangul Syllables (only some of 
them are encoded)
                         case 0xc2a0:
                             appendSpace = true;


=====================================
api/src/test/java/org/hippoecm/repository/api/UriEncodingTest.java
=====================================
--- a/api/src/test/java/org/hippoecm/repository/api/UriEncodingTest.java
+++ b/api/src/test/java/org/hippoecm/repository/api/UriEncodingTest.java
@@ -77,6 +77,9 @@ public class UriEncodingTest {
         
assertEquals("aaaaaaccccccccddddeeeeeeeeeegggggggghhhhiiiiiiiiiiijijjjkkkllllllllllnnnnnnnnnoooooooeoerrrrrrssssssssttttttuuuuuuuuuuuuwwyyyzzzzzzs",
               
uri.encode("ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſ"));
 
+        // 0x201x subrange of Unicode General Punctuation
+        assertEquals("--------with-ending", 
uri.encode("‐‑‒–—―‖‗‘’‚‛“”„‟with-ending"));
+
         // trailing dots
         assertEquals("abc", uri.encode("abc."));
         assertEquals("a", uri.encode("a..."));



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-repository/compare/b4393869670da0837ae7973e144e91a5836f6c9c...352aa381ddf906caca051b48c1654bbdbf594038

---
View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-repository/compare/b4393869670da0837ae7973e144e91a5836f6c9c...352aa381ddf906caca051b48c1654bbdbf594038
You're receiving this email because of your account on code.onehippo.org.
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to