garydgregory commented on code in PR #581: URL: https://github.com/apache/httpcomponents-client/pull/581#discussion_r1768577181
########## httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java: ########## @@ -456,4 +461,33 @@ void verifySession( } } + /** + * Sanitizes an X500Principal by escaping control characters. + * <p> + * This method processes the RFC2253 format of the X500Principal and escapes + * any ISO control characters to avoid issues in logging or other outputs. + * Control characters are replaced with their escaped hexadecimal representation. + * </p> + * + * <p><strong>Note:</strong> For testing purposes, this method is package-private + * to allow access within the same package. This allows tests to verify the correct + * behavior of the sanitization process.</p> + * + * @param principal the X500Principal to sanitize + * @return the sanitized string representation of the X500Principal + */ + @Internal + String sanitizeX500Principal(final X500Principal principal) { + final String principalValue = principal.getName(X500Principal.RFC2253); + final StringBuilder sanitizedPrincipal = new StringBuilder(); Review Comment: You could pre-allocate the `StringBuilder` to the size of the `principalValue`. -- 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-unsubscr...@hc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org