[#82706] [Ruby trunk Bug#13851] getting "can't modify string; temporarily locked" on non-frozen instances — cardoso_tiago@...
Issue #13851 has been updated by chucke (Tiago Cardoso).
3 messages
2017/09/07
[#82853] [Ruby trunk Bug#13916] Race condition when sending a signal to a new fork — russell.davis@...
Issue #13916 has been reported by russelldavis (Russell Davis).
3 messages
2017/09/19
[#82892] [Ruby trunk Bug#13921] buffered read_nonblock doesn't work as expected using SSLSocket — cardoso_tiago@...
Issue #13921 has been updated by chucke (Tiago Cardoso).
3 messages
2017/09/20
[ruby-core:83055] [Ruby trunk Bug#13949] String#unpack with 'M' directive can create strings with wrong code range
From:
ruby@...
Date:
2017-09-28 20:26:12 UTC
List:
ruby-core #83055
Issue #13949 has been reported by nirvdrum (Kevin Menard).
----------------------------------------
Bug #13949: String#unpack with 'M' directive can create strings with wrong code range
https://bugs.ruby-lang.org/issues/13949
* Author: nirvdrum (Kevin Menard)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v:
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
I've noticed that String#unpack with the 'M' directive can create strings that should be CR_7BIT as CR_VALID. The issue appears to have been introduced in r30542, which assumes that all ASCII-8BIT strings must be CR_VALID. It's possible this was correct back during Ruby 1.9.3 development and just wasn't updated. I'm not familiar enough with the history to tell.
A simple reproduction showing the issue is:
```
res = '0123456789=\n'.unpack('M').first
p res
p res.encoding
p res.bytes
p res.ascii_only?
puts
packed = res.bytes.pack('c*')
p packed
p packed.encoding
p packed.bytes
p packed.ascii_only?
```
This yields the following output:
```
"0123456789=\\n"
#<Encoding:ASCII-8BIT>
[48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 61, 92, 110]
false
"0123456789=\\n"
#<Encoding:ASCII-8BIT>
[48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 61, 92, 110]
true
```
Both strings have exactly the same contents with the same encoding. But, depending on how you construct them, one is consider to be CR_7BIT (indicated by the String#ascii_only?) value, and one is considered to be CR_VALID. I believe CR_7BIT is the correct code range value in this situation.
--
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>