ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:61402] [ruby-trunk - Bug #9618] [Open] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
@ 2014-03-10 12:27 ` daniel
  2014-03-10 13:00 ` [ruby-core:61403] [ruby-trunk - Bug #9618] " eregontp
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: daniel @ 2014-03-10 12:27 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been reported by Daniel Rikowski.

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618

* Author: Daniel Rikowski
* Status: Open
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:61403] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
  2014-03-10 12:27 ` [ruby-core:61402] [ruby-trunk - Bug #9618] [Open] Pathname#cleanpath creates mixed path separators daniel
@ 2014-03-10 13:00 ` eregontp
  2014-03-11  1:02 ` [ruby-core:61406] " nobu
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: eregontp @ 2014-03-10 13:00 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Benoit Daloze.


I agree on using / only in Pathname (converting in #initialize).

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-45712

* Author: Daniel Rikowski
* Status: Open
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:61406] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
  2014-03-10 12:27 ` [ruby-core:61402] [ruby-trunk - Bug #9618] [Open] Pathname#cleanpath creates mixed path separators daniel
  2014-03-10 13:00 ` [ruby-core:61403] [ruby-trunk - Bug #9618] " eregontp
@ 2014-03-11  1:02 ` nobu
  2014-03-11 11:07 ` [ruby-core:61410] " daniel
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: nobu @ 2014-03-11  1:02 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Nobuyoshi Nakada.


Agree.

~~~diff
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index 3db97fc..a68ecd2 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -17,6 +17,12 @@ get_strpath(VALUE obj)
 static void
 set_strpath(VALUE obj, VALUE val)
 {
+    VALUE sep[2];
+    sep[0] = rb_const_get(rb_cFile, rb_intern("ALT_SEPARATOR"));
+    if (!NIL_P(sep[0])) {
+	sep[1] = rb_const_get(rb_cFile, rb_intern("SEPARATOR"));
+	rb_funcallv(val, rb_intern("tr!"), 2, sep);
+    }
     rb_ivar_set(obj, id_at_path, val);
 }
 
~~~


----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-45715

* Author: Daniel Rikowski
* Status: Open
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:61410] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2014-03-11  1:02 ` [ruby-core:61406] " nobu
@ 2014-03-11 11:07 ` daniel
  2014-03-11 17:25 ` [ruby-core:61418] " eregontp
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: daniel @ 2014-03-11 11:07 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Daniel Rikowski.


I'm not sure if converting the separators in `#initialize` is the best way to go. I can see the advantages, but I can also imagine existing programs breaking because of that.

Personally I'd prefer a more conservative approach which would remove ALT_SEPARATOR in `#cleanpath` only.

That way `#initialize` would gain a new (minor) feature as opposed to `Pathname` losing a (major) feature. (i.e. the possibility to store file names in the native format of the current OS)

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-45720

* Author: Daniel Rikowski
* Status: Open
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:61418] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2014-03-11 11:07 ` [ruby-core:61410] " daniel
@ 2014-03-11 17:25 ` eregontp
  2014-03-11 17:42 ` [ruby-core:61419] " nobu
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: eregontp @ 2014-03-11 17:25 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Benoit Daloze.


There might be the special case of UNC paths, does anyone know if UNC paths with forward slashes work on Windows?

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-45727

* Author: Daniel Rikowski
* Status: Open
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:61419] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2014-03-11 17:25 ` [ruby-core:61418] " eregontp
@ 2014-03-11 17:42 ` nobu
  2014-03-11 18:28 ` [ruby-core:61420] " daniel
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: nobu @ 2014-03-11 17:42 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Nobuyoshi Nakada.


It works.

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-45728

* Author: Daniel Rikowski
* Status: Open
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:61420] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2014-03-11 17:42 ` [ruby-core:61419] " nobu
@ 2014-03-11 18:28 ` daniel
  2014-03-12 15:49 ` [ruby-core:61438] " eregontp
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: daniel @ 2014-03-11 18:28 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Daniel Rikowski.


I could not find anything official regarding UNC paths with forward slashes in the Win32 documentation for paths (http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx) 

So I did a few tests: They work on the command line and `CreateFile` works fine, too. Surprisingly they don't work in Explorer. Extended file names OTOH, e.g. names starting with `\\?\`, do **not** support forward slashes.

I guess even if they work officially, they are rather unusual. I suspect they'll most likely lead to some practical problems with 3rd-party apps or libs which do not share the same flexibility as the Windows kernel. 

If not even the Windows Explorer can handle them properly...

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-45729

* Author: Daniel Rikowski
* Status: Open
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:61438] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2014-03-11 18:28 ` [ruby-core:61420] " daniel
@ 2014-03-12 15:49 ` eregontp
  2014-03-13  9:11 ` [ruby-core:61457] " daniel
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: eregontp @ 2014-03-12 15:49 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Benoit Daloze.


Thanks for both of your answers!

Indeed I think I met the fact it did not work in Explorer, but if it works with the standard API that is what matters.
I would definitely go with something like nobu's solution then (the conversion should also be done when loading from JSON/yaml/etc, ideally every time @path is changed).

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-45740

* Author: Daniel Rikowski
* Status: Open
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:61457] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2014-03-12 15:49 ` [ruby-core:61438] " eregontp
@ 2014-03-13  9:11 ` daniel
  2014-03-15 14:40 ` [ruby-core:61514] " akr
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: daniel @ 2014-03-13  9:11 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Daniel Rikowski.


No problem, I'm glad to help.

To be honest I'm a little concerned that my report of such a minor problem might result in such a drastic change. 

But lets hope for the best :)



----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-45752

* Author: Daniel Rikowski
* Status: Open
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:61514] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2014-03-13  9:11 ` [ruby-core:61457] " daniel
@ 2014-03-15 14:40 ` akr
  2014-03-18  7:56 ` [ruby-core:61573] " nobu
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: akr @ 2014-03-15 14:40 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Akira Tanaka.


I like normalization in cleanpath only.

I feel normalization in initialize is too drastic.

I feel mixed separators is not clean, so it is natural to normalize in cleanpath.

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-45803

* Author: Daniel Rikowski
* Status: Open
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:61573] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2014-03-15 14:40 ` [ruby-core:61514] " akr
@ 2014-03-18  7:56 ` nobu
  2014-05-05 13:10 ` [ruby-core:62384] [ruby-trunk - Bug #9618] [Closed] " akr
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: nobu @ 2014-03-18  7:56 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Nobuyoshi Nakada.


    pathname.rb: separators
    
    * ext/pathname/lib/pathname.rb (cleanpath_aggressive): make all
      separators File::SEPARATOR from File::ALT_SEPARATOR.
      [ruby-core:61402] [Bug #9618]
    
    * ext/pathname/lib/pathname.rb (cleanpath_conservative): ditto.

	Modified   ext/pathname/lib/pathname.rb
diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb
index 20c92e2..e64432e 100644
--- a/ext/pathname/lib/pathname.rb
+++ b/ext/pathname/lib/pathname.rb
@@ -113,6 +113,7 @@ class Pathname
         end
       end
     end
+    pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
     if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
       names.shift while names[0] == '..'
     end
@@ -161,6 +162,7 @@ class Pathname
       pre, base = r
       names.unshift base if base != '.'
     end
+    pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
     if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
       names.shift while names[0] == '..'
     end
	Modified   test/pathname/test_pathname.rb
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index ed79b5b..a74dad1 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -88,6 +88,10 @@ class TestPathname < Test::Unit::TestCase
     defassert(:cleanpath_aggressive, '/',       '///a/../..')
   end
 
+  if DOSISH
+    defassert(:cleanpath_aggressive, 'c:/foo/bar', 'c:\\foo\\bar')
+  end
+
   def cleanpath_conservative(path)
     Pathname.new(path).cleanpath(true).to_s
   end
@@ -124,6 +128,10 @@ class TestPathname < Test::Unit::TestCase
   defassert(:cleanpath_conservative, '/a',     '/../.././../a')
   defassert(:cleanpath_conservative, 'a/b/../../../../c/../d', 'a/b/../../../../c/../d')
 
+  if DOSISH
+    defassert(:cleanpath_conservative, 'c:/foo/bar', 'c:\\foo\\bar')
+  end
+
   if DOSISH_UNC
     defassert(:cleanpath_conservative, '//',     '//')
   else
~~~

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-45858

* Author: Daniel Rikowski
* Status: Open
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:62384] [ruby-trunk - Bug #9618] [Closed] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2014-03-18  7:56 ` [ruby-core:61573] " nobu
@ 2014-05-05 13:10 ` akr
  2014-07-02  7:22 ` [ruby-core:63501] [ruby-trunk - Bug #9618] " usa
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: akr @ 2014-05-05 13:10 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Akira Tanaka.

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

Applied in changeset r45827.

----------
* ext/pathname/lib/pathname.rb (cleanpath_aggressive): make all
  separators File::SEPARATOR from File::ALT_SEPARATOR.
  Reported by Daniel Rikowski.
  Fixed by Nobuyoshi Nakada.  [Bug #9618]

* ext/pathname/lib/pathname.rb (cleanpath_conservative): ditto.

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-46541

* Author: Daniel Rikowski
* Status: Closed
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:63501] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2014-05-05 13:10 ` [ruby-core:62384] [ruby-trunk - Bug #9618] [Closed] " akr
@ 2014-07-02  7:22 ` usa
  2014-07-02  7:25 ` [ruby-core:63502] " usa
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 16+ messages in thread
From: usa @ 2014-07-02  7:22 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Usaku NAKAMURA.

Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN to 1.9.3: REQUIRED, 2.0.0: UNKNOWN, 2.1: REQUIRED

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-47549

* Author: Daniel Rikowski
* Status: Closed
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 1.9.3: REQUIRED, 2.0.0: UNKNOWN, 2.1: REQUIRED
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:63502] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (12 preceding siblings ...)
  2014-07-02  7:22 ` [ruby-core:63501] [ruby-trunk - Bug #9618] " usa
@ 2014-07-02  7:25 ` usa
  2014-07-23 14:06 ` [ruby-core:63979] " nagachika00
  2014-08-31  7:26 ` [ruby-core:64690] " usa
  15 siblings, 0 replies; 16+ messages in thread
From: usa @ 2014-07-02  7:25 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Usaku NAKAMURA.

Backport changed from 1.9.3: REQUIRED, 2.0.0: UNKNOWN, 2.1: REQUIRED to 2.0.0: REQUIRED, 2.1: REQUIRED

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-47550

* Author: Daniel Rikowski
* Status: Closed
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:63979] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (13 preceding siblings ...)
  2014-07-02  7:25 ` [ruby-core:63502] " usa
@ 2014-07-23 14:06 ` nagachika00
  2014-08-31  7:26 ` [ruby-core:64690] " usa
  15 siblings, 0 replies; 16+ messages in thread
From: nagachika00 @ 2014-07-23 14:06 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Tomoyuki Chikanaga.

Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE

Backported into `ruby_2_1` branch at r46911.

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-47998

* Author: Daniel Rikowski
* Status: Closed
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 2.0.0: REQUIRED, 2.1: DONE
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

* [ruby-core:64690] [ruby-trunk - Bug #9618] Pathname#cleanpath creates mixed path separators
       [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
                   ` (14 preceding siblings ...)
  2014-07-23 14:06 ` [ruby-core:63979] " nagachika00
@ 2014-08-31  7:26 ` usa
  15 siblings, 0 replies; 16+ messages in thread
From: usa @ 2014-08-31  7:26 UTC (permalink / raw
  To: ruby-core

Issue #9618 has been updated by Usaku NAKAMURA.

Backport changed from 2.0.0: REQUIRED, 2.1: DONE to 2.0.0: DONE, 2.1: DONE

backported into `ruby_2_0_0` at r47337.

----------------------------------------
Bug #9618: Pathname#cleanpath creates mixed path separators
https://bugs.ruby-lang.org/issues/9618#change-48586

* Author: Daniel Rikowski
* Status: Closed
* Priority: Low
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
* Backport: 2.0.0: DONE, 2.1: DONE
----------------------------------------
When using `Pathname#cleanpath` with a Windows path the resulting path contains a mixture of slashes and backslashes.

~~~
require 'pathname'
path = Pathname.new('c:\projects\ruby\bug\test.rb')
path.to_s               # => "c:\\projects\\ruby\\bug\\test.rb"
path.cleanpath.to_s     # => "c:\\projects/ruby/bug/test.rb"
~~~ 

I'd expect `cleanpath` to use the same path separator for all path segments. The problem doesn't happen on non-Windows platforms because there backslashes are not detected as path separators.

The problem is that the first path segment is added verbatim and only subsequent segments are joined by `File::join`.

Personally I'd prefer it to use `File::SEPARATOR` **only**, regardless of any original separator(s). That way it would blend with the current 'normalizing' behaviour of `cleanpath`, which then could be also used to normalize any existing separator weirdness and - for example - make a path compatible with `Dir.glob` (which can't use backslashes)





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

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

end of thread, other threads:[~2014-08-31  7:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-9618.20140310122758@ruby-lang.org>
2014-03-10 12:27 ` [ruby-core:61402] [ruby-trunk - Bug #9618] [Open] Pathname#cleanpath creates mixed path separators daniel
2014-03-10 13:00 ` [ruby-core:61403] [ruby-trunk - Bug #9618] " eregontp
2014-03-11  1:02 ` [ruby-core:61406] " nobu
2014-03-11 11:07 ` [ruby-core:61410] " daniel
2014-03-11 17:25 ` [ruby-core:61418] " eregontp
2014-03-11 17:42 ` [ruby-core:61419] " nobu
2014-03-11 18:28 ` [ruby-core:61420] " daniel
2014-03-12 15:49 ` [ruby-core:61438] " eregontp
2014-03-13  9:11 ` [ruby-core:61457] " daniel
2014-03-15 14:40 ` [ruby-core:61514] " akr
2014-03-18  7:56 ` [ruby-core:61573] " nobu
2014-05-05 13:10 ` [ruby-core:62384] [ruby-trunk - Bug #9618] [Closed] " akr
2014-07-02  7:22 ` [ruby-core:63501] [ruby-trunk - Bug #9618] " usa
2014-07-02  7:25 ` [ruby-core:63502] " usa
2014-07-23 14:06 ` [ruby-core:63979] " nagachika00
2014-08-31  7:26 ` [ruby-core:64690] " usa

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