[#76442] [Ruby trunk Feature#11741] Migrate Ruby to Git from Subversion — naruse@...
Issue #11741 has been updated by Yui NARUSE.
3 messages
2016/07/19
[#76515] [Ruby trunk Bug#12610] webrick: protect from httpoxy — nagachika00@...
Issue #12610 has been updated by Tomoyuki Chikanaga.
3 messages
2016/07/22
[ruby-core:76611] [Ruby trunk Bug#12636] string.gsub(/([a-z](?=[A-Z._ ]))/, "#{$1} ") returns wrong result (possible C-string leak?)
From:
merch-redmine@...
Date:
2016-07-29 15:01:24 UTC
List:
ruby-core #76611
Issue #12636 has been updated by Jeremy Evans.
This isn't a bug, it's because "#{$1} " is evaluated before the call to gsub, using the results of the previous regexp match. You probably want to use '\1 ' instead.
----------------------------------------
Bug #12636: string.gsub(/([a-z](?=[A-Z._ ]))/, "#{$1} ") returns wrong result (possible C-string leak?)
https://bugs.ruby-lang.org/issues/12636#change-59830
* Author: Mike McFadden
* Status: Open
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Verified in Ruby 2.1, 2.2, and 2.3.
> "Hello.World".gsub(/([a-z](?=[A-Z._ ]))/, "#{$1} ")
=> "Hell .World"
^ wrong answer; it should be `"Hello .World"`
> "Hello.World".gsub(/([a-z](?=[A-Z._ ]))/, "#{$1} ")
=> "Hello .World"
^ running it a second time in the same IRB session now returns the correct result, however...
> "Help.World".gsub(/([a-z](?=[A-Z._ ]))/, "#{$1} ")
=> "Helo .World"
^ now the p turned into an o somehow? It's clearly retaining strings from the previous invocation and reusing them, but not updating every byte.
Here's the equivalent code in JavaScript, which returns the correct result every time:
"Hello.World".replace(/([a-z](?=[A-Z._ ]))/g, "$1 ")
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>