ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:45062] [ruby-trunk - Bug #6436][Open] Byte counting incorrect in BufferedIO (net/protocol.rb)
@ 2012-05-15 20:10 jcast (Jeremie Castagna)
  2012-05-15 20:27 ` [ruby-core:45063] [ruby-trunk - Bug #6436] " jcast (Jeremie Castagna)
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: jcast (Jeremie Castagna) @ 2012-05-15 20:10 UTC (permalink / raw)
  To: ruby-core


Issue #6436 has been reported by jcast (Jeremie Castagna).

----------------------------------------
Bug #6436: Byte counting incorrect in BufferedIO (net/protocol.rb)
https://bugs.ruby-lang.org/issues/6436

Author: jcast (Jeremie Castagna)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: 1.9


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


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:45063] [ruby-trunk - Bug #6436] Byte counting incorrect in BufferedIO (net/protocol.rb)
  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 ` jcast (Jeremie Castagna)
  2012-05-15 23:52   ` [ruby-core:45068] " Eric Wong
  2012-05-16  1:05 ` [ruby-core:45070] " nobu (Nobuyoshi Nakada)
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: jcast (Jeremie Castagna) @ 2012-05-15 20:27 UTC (permalink / raw)
  To: ruby-core


Issue #6436 has been updated by jcast (Jeremie Castagna).

File protocol.patch added

Patch file.
----------------------------------------
Bug #6436: Byte counting incorrect in BufferedIO (net/protocol.rb)
https://bugs.ruby-lang.org/issues/6436#change-26645

Author: jcast (Jeremie Castagna)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: 1.9


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


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:45068] Re: [ruby-trunk - Bug #6436] Byte counting incorrect in BufferedIO (net/protocol.rb)
  2012-05-15 20:27 ` [ruby-core:45063] [ruby-trunk - Bug #6436] " jcast (Jeremie Castagna)
@ 2012-05-15 23:52   ` Eric Wong
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2012-05-15 23:52 UTC (permalink / raw)
  To: ruby-core

"jcast (Jeremie Castagna)" <jeremie.castagna@gmail.com> wrote:
> File protocol.patch added
> 
> Patch file.

Can you send the patch with unified diff format?  (diff -u)

It's the default format of both svn and git, and generally easier to
read/review.  Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:45070] [ruby-trunk - Bug #6436] Byte counting incorrect in BufferedIO (net/protocol.rb)
  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-16  1:05 ` nobu (Nobuyoshi Nakada)
  2012-05-16 16:03 ` [ruby-core:45094] [ruby-trunk - Bug #6436][Assigned] " mame (Yusuke Endoh)
  2019-08-15  1:41 ` [ruby-core:94361] [Ruby master Bug#6436] " merch-redmine
  3 siblings, 0 replies; 6+ messages in thread
From: nobu (Nobuyoshi Nakada) @ 2012-05-16  1:05 UTC (permalink / raw)
  To: ruby-core


Issue #6436 has been updated by nobu (Nobuyoshi Nakada).

File protocol.patch added

Emacs diff-mode.el provides a function, diff-context->unified.
----------------------------------------
Bug #6436: Byte counting incorrect in BufferedIO (net/protocol.rb)
https://bugs.ruby-lang.org/issues/6436#change-26649

Author: jcast (Jeremie Castagna)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: 1.9


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


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:45094] [ruby-trunk - Bug #6436][Assigned] Byte counting incorrect in BufferedIO (net/protocol.rb)
  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-16  1:05 ` [ruby-core:45070] " nobu (Nobuyoshi Nakada)
@ 2012-05-16 16:03 ` mame (Yusuke Endoh)
  2019-08-15  1:41 ` [ruby-core:94361] [Ruby master Bug#6436] " merch-redmine
  3 siblings, 0 replies; 6+ messages in thread
From: mame (Yusuke Endoh) @ 2012-05-16 16:03 UTC (permalink / raw)
  To: ruby-core


Issue #6436 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to nobu (Nobuyoshi Nakada)

Thanks Jeremie,
Could you add a test to test/net/http/test_buffered_io.rb ?

Nobu, can you review the patch?

-- 
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Bug #6436: Byte counting incorrect in BufferedIO (net/protocol.rb)
https://bugs.ruby-lang.org/issues/6436#change-26667

Author: jcast (Jeremie Castagna)
Status: Assigned
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: 
Target version: 
ruby -v: 1.9


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


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:94361] [Ruby master Bug#6436] Byte counting incorrect in BufferedIO (net/protocol.rb)
  2012-05-15 20:10 [ruby-core:45062] [ruby-trunk - Bug #6436][Open] Byte counting incorrect in BufferedIO (net/protocol.rb) jcast (Jeremie Castagna)
                   ` (2 preceding siblings ...)
  2012-05-16 16:03 ` [ruby-core:45094] [ruby-trunk - Bug #6436][Assigned] " mame (Yusuke Endoh)
@ 2019-08-15  1:41 ` merch-redmine
  3 siblings, 0 replies; 6+ messages in thread
From: merch-redmine @ 2019-08-15  1:41 UTC (permalink / raw)
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-08-15  1:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [ruby-core:94361] [Ruby master Bug#6436] " merch-redmine

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).