You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "arturobernalg (via GitHub)" <gi...@apache.org> on 2026/10/21 11:13:59 UTC
[PR] Filter control characters in encoded HTTP/1 output lines [httpcomponents-core]
arturobernalg opened a new pull request, #725:
URL: https://github.com/apache/httpcomponents-core/pull/725
Prevent control characters from being emitted in HTTP/1 output lines when an explicit charset encoder is configured.
Apply the same filtering as the default encoding path in both classic and async session output buffers, without affecting binary output or introducing additional overhead in the default path.
--
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
Re: [PR] Filter control characters in encoded HTTP/1 output lines [httpcomponents-core]
Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg merged PR #725:
URL: https://github.com/apache/httpcomponents-core/pull/725
--
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
Re: [PR] Filter control characters in encoded HTTP/1 output lines [httpcomponents-core]
Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #725:
URL: https://github.com/apache/httpcomponents-core/pull/725#discussion_r4337036105
##########
httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionOutputBufferImpl.java:
##########
@@ -198,7 +198,16 @@ public void writeLine(final CharArrayBuffer lineBuffer) throws CharacterCodingEx
// terminate the encoding process
eol = true;
}
+ // Filter controls while copying into the encoder's staging buffer.
+ final int start = this.charbuffer.position();
this.charbuffer.put(lineBuffer.array(), offset, l);
Review Comment:
@arturobernalg I would do the input sanitization here while coping from `lineBuffer` to `charbuffer`.
##########
httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionOutputBufferImpl.java:
##########
@@ -198,7 +198,16 @@ public void writeLine(final CharArrayBuffer lineBuffer) throws CharacterCodingEx
// terminate the encoding process
eol = true;
}
+ // Filter controls while copying into the encoder's staging buffer.
+ final int start = this.charbuffer.position();
this.charbuffer.put(lineBuffer.array(), offset, l);
+ final int end = this.charbuffer.position();
+ for (int i = start; i < end; i++) {
+ final char ch = this.charbuffer.get(i);
+ if (ch < 0x20 && ch != '\t' || ch >= 0x7f && ch <= 0x9f) {
Review Comment:
@arturobernalg Ideally this logic should provided by `TextUtils` and shared with `castAsByte`
--
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