From: merch-redmine@jeremyevans.net
To: ruby-core@ruby-lang.org
Subject: [ruby-core:94361] [Ruby master Bug#6436] Byte counting incorrect in BufferedIO (net/protocol.rb)
Date: Thu, 15 Aug 2019 01:41:41 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-80771.20190815014140.a835fc685678ff31@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-6436.20120516050958@ruby-lang.org
Issue #6436 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Assigned to Closed
It looks like this issue was fixed between Ruby 2.4 and 2.5:
```
$ ruby24 -rnet/http -e "p Net::HTTP.start('www.falcom.co.jp', 443, :use_ssl=>true){|http| http.request_get('/'){|res| res.read_body{|c| p c.bytesize; c.force_encoding 'UTF-8'}}}"
0
16384
16384
16384
4604
2
5
0
16384
16384
16384
4604
2
5
-e: end of file reached (EOFError)
$ ruby24 -rnet/http -e "p Net::HTTP.start('www.falcom.co.jp', 443, :use_ssl=>true){|http| http.request_get('/'){|res| res.read_body{|c| p c.bytesize}}}"
0
16384
16384
16384
4604
#<Net::HTTPOK 200 OK readbody=true>
$ ruby25 -rnet/http -e "p Net::HTTP.start('www.falcom.co.jp', 443, :use_ssl=>true){|http| http.request_get('/'){|res| res.read_body{|c| p c.bytesize; c.force_encoding 'UTF-8'}}}"
0
16384
16384
16384
4604
#<Net::HTTPOK 200 OK readbody=true>
```
----------------------------------------
Bug #6436: Byte counting incorrect in BufferedIO (net/protocol.rb)
https://bugs.ruby-lang.org/issues/6436#change-80771
* Author: jcast (Jeremie Castagna)
* Status: Closed
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version:
* ruby -v: 1.9
* Backport:
----------------------------------------
BufferedIO's @rbuf counts bytes with String#size, but should use String#bytesize. This creates potential incorrect reading of a HTTP body when changing the encoding of each chuck passed by HTTP#read_body:
http.read_body do |chunk|
chunk.force_encoding "UTF-8"
end
---Files--------------------------------
protocol.patch (4.39 KB)
protocol.patch (2.63 KB)
--
https://bugs.ruby-lang.org/
prev parent reply other threads:[~2019-08-15 1:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-15 20:10 [ruby-core:45062] [ruby-trunk - Bug #6436][Open] Byte counting incorrect in BufferedIO (net/protocol.rb) jcast (Jeremie Castagna)
2012-05-15 20:27 ` [ruby-core:45063] [ruby-trunk - Bug #6436] " jcast (Jeremie Castagna)
2012-05-15 23:52 ` [ruby-core:45068] " Eric Wong
2012-05-16 1:05 ` [ruby-core:45070] " nobu (Nobuyoshi Nakada)
2012-05-16 16:03 ` [ruby-core:45094] [ruby-trunk - Bug #6436][Assigned] " mame (Yusuke Endoh)
2019-08-15 1:41 ` merch-redmine [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-80771.20190815014140.a835fc685678ff31@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).