arturobernalg commented on code in PR #416: URL: https://github.com/apache/httpcomponents-core/pull/416#discussion_r1300585619
########## httpcore5/src/main/java/org/apache/hc/core5/util/TextUtils.java: ########## @@ -141,4 +142,20 @@ return s.toLowerCase(Locale.ROOT); } + /** + * Filter characters before byte conversion + * + * @since 5.2 + */ + @Internal + public static byte filterIfRequired(final int c) { + if ((c >= 0x20 && c <= 0x7E) || // Visible ASCII + (c >= 0xA0 && c <= 0xFF) || // Visible ISO-8859-1 + c == 0x09) { // TAB + return (byte) c; Review Comment: @vismayku I think you need to ensure unexpected truncation by checking the range of the input before performing the cast. ``` if (c <= 127) { // Ensure it's within byte range return (byte) c; } ``` -- 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