mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
* Strip header whitespace in C Fix #1890 Co-authored-by: Matthew Draper <matthew@trebex.net> * Add Java extension to do the same Co-authored-by: Charles Nutter <headius@headius.com> * Changelog
This commit is contained in:
parent
2d46f0b63a
commit
22b135a636
4 changed files with 9 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
* Features
|
||||
* Your feature goes here (#Github Number)
|
||||
* Strip whitespace at end of HTTP headers (#2010)
|
||||
|
||||
* Bugfixes
|
||||
* Your bugfix goes here (#Github Number)
|
||||
|
|
|
@ -87,7 +87,9 @@ public class Http11 extends RubyObject {
|
|||
validateMaxLength(flen, MAX_FIELD_NAME_LENGTH, MAX_FIELD_NAME_LENGTH_ERR);
|
||||
validateMaxLength(vlen, MAX_FIELD_VALUE_LENGTH, MAX_FIELD_VALUE_LENGTH_ERR);
|
||||
|
||||
ByteList b = new ByteList(Http11.this.hp.parser.buffer,field,flen);
|
||||
ByteList buffer = Http11.this.hp.parser.buffer;
|
||||
|
||||
ByteList b = new ByteList(buffer,field,flen);
|
||||
for(int i = 0,j = b.length();i<j;i++) {
|
||||
if((b.get(i) & 0xFF) == '-') {
|
||||
b.set(i, (byte)'_');
|
||||
|
@ -105,7 +107,9 @@ public class Http11 extends RubyObject {
|
|||
f.cat(b);
|
||||
}
|
||||
|
||||
b = new ByteList(Http11.this.hp.parser.buffer, value, vlen);
|
||||
while (vlen > 0 && Character.isWhitespace(buffer.get(value + vlen - 1))) vlen--;
|
||||
|
||||
b = new ByteList(buffer, value, vlen);
|
||||
v = req.op_aref(req.getRuntime().getCurrentContext(), f);
|
||||
if (v.isNil()) {
|
||||
req.op_aset(req.getRuntime().getCurrentContext(), f, RubyString.newString(runtime, b));
|
||||
|
|
|
@ -200,6 +200,8 @@ void http_field(puma_parser* hp, const char *field, size_t flen,
|
|||
f = rb_str_new(hp->buf, new_size);
|
||||
}
|
||||
|
||||
while (vlen > 0 && isspace(value[vlen - 1])) vlen--;
|
||||
|
||||
/* check for duplicate header */
|
||||
v = rb_hash_aref(hp->request, f);
|
||||
|
||||
|
|
|
@ -199,9 +199,7 @@ class Http11ParserTest < Minitest::Test
|
|||
end
|
||||
end
|
||||
|
||||
# https://github.com/puma/puma/issues/1890
|
||||
def test_trims_whitespace_from_headers
|
||||
skip("Known failure, see issue 1890 on GitHub")
|
||||
parser = Puma::HttpParser.new
|
||||
req = {}
|
||||
http = "GET / HTTP/1.1\r\nX-Strip-Me: Strip This \r\n\r\n"
|
||||
|
|
Loading…
Reference in a new issue