You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by GitBox <gi...@apache.org> on 2022/05/16 01:06:49 UTC

[GitHub] [directory-studio] roubert commented on a diff in pull request #32: DIRSTUDIO-1296: Decode RFC 4517 Postal Address syntax upon export

roubert commented on code in PR #32:
URL: https://github.com/apache/directory-studio/pull/32#discussion_r873258520


##########
plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/Utils.java:
##########
@@ -657,4 +657,34 @@ private static LdifAttrValLine computeDiffCreateAttrValLine( IValue value )
             return LdifAttrValLine.create( attribute.getDescription(), value.getStringValue() );
         }
     }
+
+
+    /** OID of the RFC 4517 Postal Address syntax. */
+    public static final String POSTAL_ADDRESS_SYNTAX_OID = "1.3.6.1.4.1.1466.115.121.1.41";

Review Comment:
   Done.



##########
plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/Utils.java:
##########
@@ -657,4 +657,34 @@ private static LdifAttrValLine computeDiffCreateAttrValLine( IValue value )
             return LdifAttrValLine.create( attribute.getDescription(), value.getStringValue() );
         }
     }
+
+
+    /** OID of the RFC 4517 Postal Address syntax. */
+    public static final String POSTAL_ADDRESS_SYNTAX_OID = "1.3.6.1.4.1.1466.115.121.1.41";
+
+
+    /**
+     * Decodes the RFC 4517 Postal Address syntax.
+     *
+     * <pre>
+     * PostalAddress = line *( DOLLAR line )
+     * line          = 1*line-char
+     * line-char     = %x00-23
+     *                 / (%x5C "24")  ; escaped "$"
+     *                 / %x25-5B
+     *                 / (%x5C "5C")  ; escaped "\"
+     *                 / %x5D-7F
+     *                 / UTFMB
+     * </pre>
+     *
+     * @param input the encoded string
+     * @param separator the separator to output between address lines
+     * @return the decoded string
+     */
+    public static String decodePostalAddress( String input, String separator )
+    {
+        return input.replaceAll( "\\$", separator ) //$NON-NLS-1$
+            .replaceAll( "\\\\24", "\\$" ) //$NON-NLS-1$ //$NON-NLS-2$
+            .replaceAll( "(?i)(?<=\\\\)5C", "" ); //$NON-NLS-1$ //$NON-NLS-2$

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@directory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@directory.apache.org
For additional commands, e-mail: dev-help@directory.apache.org