prosgarz35 commented on code in PR #3194:
URL: https://github.com/apache/james-project/pull/3194#discussion_r4091080862


##########
server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java:
##########
@@ -157,6 +157,54 @@ private static void closeBrowser(QueueBrowser browser) {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(JMSCacheableMailQueue.class);
 
     public static final String FORCE_DELIVERY = "FORCE_DELIVERY";
+    private static final String JAMES_MAIL_ATTR_PROP_PREFIX = "JAMES_ATTR_";
+
+    protected static String encodeAttributePropertyName(String attributeName) {
+        StringBuilder sb = new StringBuilder(JAMES_MAIL_ATTR_PROP_PREFIX);
+        for (int i = 0; i < attributeName.length(); i++) {
+            char c = attributeName.charAt(i);
+            if (Character.isJavaIdentifierPart(c)) {
+                sb.append(c);
+            } else {
+                sb.append(String.format("_%04x_", (int) c));
+            }
+        }
+        return sb.toString();
+    }
+
+    protected static String encodePerRecipientHeaderPropertyName(String 
recipientAddress) {
+        StringBuilder sb = new 
StringBuilder(JAMES_MAIL_PER_RECIPIENT_HEADERS).append('_');
+        for (int i = 0; i < recipientAddress.length(); i++) {
+            char c = recipientAddress.charAt(i);
+            if (Character.isJavaIdentifierPart(c)) {
+                sb.append(c);
+            } else {
+                sb.append(String.format("_%04x_", (int) c));
+            }
+        }
+        return sb.toString();
+    }
+
+    protected static String decodePerRecipientHeaderPropertyName(String 
propertyName) {
+        String encoded = 
propertyName.substring((JAMES_MAIL_PER_RECIPIENT_HEADERS + "_").length());
+        StringBuilder sb = new StringBuilder();
+        int i = 0;
+        while (i < encoded.length()) {
+            if (encoded.charAt(i) == '_' && i + 5 < encoded.length() && 
encoded.charAt(i + 5) == '_') {
+                try {
+                    int charCode = Integer.parseInt(encoded.substring(i + 1, i 
+ 5), 16);
+                    sb.append((char) charCode);
+                    i += 6;
+                    continue;
+                } catch (NumberFormatException e) {
+                    // Not encoded hex, fall through
+                }
+            }
+            sb.append(encoded.charAt(i));
+            i++;
+        }
+        return sb.toString();
+    }

Review Comment:
   > This needs a dedicated test suite IMO
   
   Thanks alot! I think just a little and its going be stable.
   This thing cost alot of time and about 30 millions tokens.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to