You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "ok2c (via GitHub)" <gi...@apache.org> on 2023/08/21 20:11:37 UTC
[GitHub] [httpcomponents-core] ok2c commented on a diff in pull request #416: Filter characters before byte conversion
ok2c commented on code in PR #416:
URL: https://github.com/apache/httpcomponents-core/pull/416#discussion_r1300599092
##########
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.
@arturobernalg I think the existing implementation already does that. All non-printable as well as all non-ascii characters get converted to `?`. This is expected behavior.
--
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@hc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org