Project

General

Profile

Backport #5911

File.expand_path produces malfunction string (it doesn't change on #encode)

Added by funny_falcon (Yura Sokolov) almost 8 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
[ruby-core:42179]

Description

ruby-1.9.3-p0 :018 > a = "/\u043f\u0440\u0438\u0432\u0435\u0442"
 => "/привет" 
ruby-1.9.3-p0 :019 > a.bytes.to_a
 => [47, 208, 191, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130] 
ruby-1.9.3-p0 :020 > a.encoding
 => #<Encoding:UTF-8> 
ruby-1.9.3-p0 :021 > b = a.encode('cp1251')
 => "/\xEF\xF0\xE8\xE2\xE5\xF2" 
ruby-1.9.3-p0 :022 > b.bytes.to_a
 => [47, 239, 240, 232, 226, 229, 242] 
ruby-1.9.3-p0 :023 > b.encoding
 => #<Encoding:Windows-1251> 
ruby-1.9.3-p0 :024 > c = File.expand_path(b)
 => "/\xEF\xF0\xE8\xE2\xE5\xF2" 
ruby-1.9.3-p0 :025 > c.bytes.to_a
 => [47, 239, 240, 232, 226, 229, 242] 
ruby-1.9.3-p0 :026 > c.encoding
 => #<Encoding:Windows-1251> 
ruby-1.9.3-p0 :027 > d = c.encode('utf-8')
 => "/\xEF\xF0\xE8\xE2\xE5\xF2" 
ruby-1.9.3-p0 :028 > d.bytes.to_a
 => [47, 239, 240, 232, 226, 229, 242] 
ruby-1.9.3-p0 :029 > d.encoding
 => #<Encoding:UTF-8> 
ruby-1.9.3-p0 :030 > b == c
 => true 
ruby-1.9.3-p0 :031 > a == d
 => false 
ruby-1.9.3-p0 :032 > c.force_encoding(c.encoding)
 => "/\xEF\xF0\xE8\xE2\xE5\xF2" 
ruby-1.9.3-p0 :033 > e = c.encode('utf-8')
 => "/привет" 
ruby-1.9.3-p0 :034 > e.bytes.to_a
 => [47, 208, 191, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130] 
ruby-1.9.3-p0 :035 > e.encoding
 => #<Encoding:UTF-8> 
ruby-1.9.3-p0 :036 > a == e
 => true 

Initially I found this bug in Windows (with RubyInstaller).
It confirmed in Linux with ruby installed by rvm,
but not confirmed when I install same version from git repository to other path :(
So that I think bug exists, but it is very hidden.


Related issues

Related to Backport193 - Backport #5533: Pathname's raising "invalid sequence"Closed11/01/2011Actions

Associated revisions

Revision 0e305c5a
Added by naruse (Yui NARUSE) almost 8 years ago

merge revision(s) 33603: [Backport #5533] [Backport #5911]

    * file.c (file_expand_path): reset coderange after expanding path.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 34441
Added by naruse (Yui NARUSE) almost 8 years ago

merge revision(s) 33603: [Backport #5533] [Backport #5911]

* file.c (file_expand_path): reset coderange after expanding path.

History

#1

Updated by naruse (Yui NARUSE) almost 8 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193
  • Category deleted (core)
  • Target version deleted (1.9.3)

r33603 fixes this.

Updated by funny_falcon (Yura Sokolov) almost 8 years ago

I tried install from source again to the different directory, and bug exposed.
Bug had found in 'v1_9_3_0' tag and current 'ruby_1_9_3' branch (source got from github).
Bug hadn't found in trunk branch.

Updated by funny_falcon (Yura Sokolov) almost 8 years ago

O, sorry, I didn't refresh browser before sending comment.

#4

Updated by naruse (Yui NARUSE) almost 8 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r34441.
Yura, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 33603: [Backport #5533] [Backport #5911]

* file.c (file_expand_path): reset coderange after expanding path.

Also available in: Atom PDF