ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:86377] [Ruby trunk Feature#14643] Remove problematic separator '\0' of Dir.glob and Dir.[]
       [not found] <redmine.issue-14643.20180329035217@ruby-lang.org>
@ 2018-03-29  3:52 ` usa
  2018-03-30 11:13 ` [ruby-core:86404] " shevegen
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: usa @ 2018-03-29  3:52 UTC (permalink / raw
  To: ruby-core

Issue #14643 has been reported by usa (Usaku NAKAMURA).

----------------------------------------
Feature #14643: Remove problematic separator '\0' of Dir.glob and Dir.[]
https://bugs.ruby-lang.org/issues/14643

* Author: usa (Usaku NAKAMURA)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
`Dir.glob` and `Dir.[]` accepts `'\0'` separated string as the parameter,
but this feature is very problematic.
Shouldn't we remove this feature for Ruby3 ?



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

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

* [ruby-core:86404] [Ruby trunk Feature#14643] Remove problematic separator '\0' of Dir.glob and Dir.[]
       [not found] <redmine.issue-14643.20180329035217@ruby-lang.org>
  2018-03-29  3:52 ` [ruby-core:86377] [Ruby trunk Feature#14643] Remove problematic separator '\0' of Dir.glob and Dir.[] usa
@ 2018-03-30 11:13 ` shevegen
  2018-03-30 13:28 ` [ruby-core:86405] " nobu
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: shevegen @ 2018-03-30 11:13 UTC (permalink / raw
  To: ruby-core

Issue #14643 has been updated by shevegen (Robert A. Heiler).


If it is to be removed, and it is decided to remove in ruby3,
perhaps a warning could be shown in next upcoming releases of
ruby, that this will no longer be supported, e. g. a bit similar
in how the '|' character is no longer supported as-is.

https://github.com/ruby/ruby/blob/trunk/NEWS#compatibility-issues-excluding-feature-bug-fixes

(I write if because I have no idea how ruby people use this
functionality. I myself never used '\0' and neither the '|'
character either so I could not tell. I am just saying it
in regards to whether this will change for ruby3.x)

----------------------------------------
Feature #14643: Remove problematic separator '\0' of Dir.glob and Dir.[]
https://bugs.ruby-lang.org/issues/14643#change-71333

* Author: usa (Usaku NAKAMURA)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
`Dir.glob` and `Dir.[]` accepts `'\0'` separated string as the parameter,
but this feature is very problematic.
Shouldn't we remove this feature for Ruby3 ?



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

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

* [ruby-core:86405] [Ruby trunk Feature#14643] Remove problematic separator '\0' of Dir.glob and Dir.[]
       [not found] <redmine.issue-14643.20180329035217@ruby-lang.org>
  2018-03-29  3:52 ` [ruby-core:86377] [Ruby trunk Feature#14643] Remove problematic separator '\0' of Dir.glob and Dir.[] usa
  2018-03-30 11:13 ` [ruby-core:86404] " shevegen
@ 2018-03-30 13:28 ` nobu
  2018-03-30 13:39 ` [ruby-core:86406] " nobu
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: nobu @ 2018-03-30 13:28 UTC (permalink / raw
  To: ruby-core

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


```diff
diff --git a/dir.c b/dir.c
index 6d2bedf557..432db031e9 100644
--- a/dir.c
+++ b/dir.c
@@ -2536,6 +2536,7 @@ rb_push_glob(VALUE str, VALUE base, int flags) /* '\0' is delimiter */
     long offset = 0;
     long len;
     VALUE ary;
+    int warned = FALSE;
 
     /* can contain null bytes as separators */
     if (!RB_TYPE_P((str), T_STRING)) {
@@ -2553,6 +2554,9 @@ rb_push_glob(VALUE str, VALUE base, int flags) /* '\0' is delimiter */
         const char *pbeg = RSTRING_PTR(str), *p = pbeg + offset;
         const char *pend = memchr(p, '\0', rest);
         if (pend) {
+            if (!warned) {
+                rb_warn("use Array of glob patterns instead of nul-separated patterns");
+            }
             rest = ++pend - p;
             offset = pend - pbeg;
         }
```

----------------------------------------
Feature #14643: Remove problematic separator '\0' of Dir.glob and Dir.[]
https://bugs.ruby-lang.org/issues/14643#change-71334

* Author: usa (Usaku NAKAMURA)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
`Dir.glob` and `Dir.[]` accepts `'\0'` separated string as the parameter,
but this feature is very problematic.
Shouldn't we remove this feature for Ruby3 ?



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

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

* [ruby-core:86406] [Ruby trunk Feature#14643] Remove problematic separator '\0' of Dir.glob and Dir.[]
       [not found] <redmine.issue-14643.20180329035217@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2018-03-30 13:28 ` [ruby-core:86405] " nobu
@ 2018-03-30 13:39 ` nobu
  2018-04-19  6:55 ` [ruby-core:86591] " matz
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: nobu @ 2018-03-30 13:39 UTC (permalink / raw
  To: ruby-core

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


I've missed to set `warned` flag, and rubyspec shows the warning.

```diff
diff --git a/spec/ruby/core/dir/shared/glob.rb b/spec/ruby/core/dir/shared/glob.rb
index 40973995c1..2fe22ac6c3 100644
--- a/spec/ruby/core/dir/shared/glob.rb
+++ b/spec/ruby/core/dir/shared/glob.rb
@@ -25,9 +25,11 @@
     Dir.send(@method, obj).should == %w[file_one.ext]
   end
 
-  it "splits the string on \\0 if there is only one string given" do
-    Dir.send(@method, "file_o*\0file_t*").should ==
-             %w!file_one.ext file_two.ext!
+  ruby_version_is ""..."2.6" do
+    it "splits the string on \\0 if there is only one string given" do
+      Dir.send(@method, "file_o*\0file_t*").should ==
+        %w!file_one.ext file_two.ext!
+    end
   end
 
   it "matches non-dotfiles with '*'" do
```

----------------------------------------
Feature #14643: Remove problematic separator '\0' of Dir.glob and Dir.[]
https://bugs.ruby-lang.org/issues/14643#change-71335

* Author: usa (Usaku NAKAMURA)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
`Dir.glob` and `Dir.[]` accepts `'\0'` separated string as the parameter,
but this feature is very problematic.
Shouldn't we remove this feature for Ruby3 ?



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

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

* [ruby-core:86591] [Ruby trunk Feature#14643] Remove problematic separator '\0' of Dir.glob and Dir.[]
       [not found] <redmine.issue-14643.20180329035217@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2018-03-30 13:39 ` [ruby-core:86406] " nobu
@ 2018-04-19  6:55 ` matz
  2019-09-02  0:30 ` [ruby-core:94708] [Ruby master " mame
  2019-09-02  3:06 ` [ruby-core:94709] " nobu
  6 siblings, 0 replies; 7+ messages in thread
From: matz @ 2018-04-19  6:55 UTC (permalink / raw
  To: ruby-core

Issue #14643 has been updated by matz (Yukihiro Matsumoto).


LGTM. The change will reduce the potential security risk.

Matz.


----------------------------------------
Feature #14643: Remove problematic separator '\0' of Dir.glob and Dir.[]
https://bugs.ruby-lang.org/issues/14643#change-71536

* Author: usa (Usaku NAKAMURA)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
`Dir.glob` and `Dir.[]` accepts `'\0'` separated string as the parameter,
but this feature is very problematic.
Shouldn't we remove this feature for Ruby3 ?



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

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

* [ruby-core:94708] [Ruby master Feature#14643] Remove problematic separator '\0' of Dir.glob and Dir.[]
       [not found] <redmine.issue-14643.20180329035217@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2018-04-19  6:55 ` [ruby-core:86591] " matz
@ 2019-09-02  0:30 ` mame
  2019-09-02  3:06 ` [ruby-core:94709] " nobu
  6 siblings, 0 replies; 7+ messages in thread
From: mame @ 2019-09-02  0:30 UTC (permalink / raw
  To: ruby-core

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

Status changed from Closed to Open

Will this behavior be removed in 2.7?

----------------------------------------
Feature #14643: Remove problematic separator '\0' of Dir.glob and Dir.[]
https://bugs.ruby-lang.org/issues/14643#change-81318

* Author: usa (Usaku NAKAMURA)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
`Dir.glob` and `Dir.[]` accepts `'\0'` separated string as the parameter,
but this feature is very problematic.
Shouldn't we remove this feature for Ruby3 ?



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

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

* [ruby-core:94709] [Ruby master Feature#14643] Remove problematic separator '\0' of Dir.glob and Dir.[]
       [not found] <redmine.issue-14643.20180329035217@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2019-09-02  0:30 ` [ruby-core:94708] [Ruby master " mame
@ 2019-09-02  3:06 ` nobu
  6 siblings, 0 replies; 7+ messages in thread
From: nobu @ 2019-09-02  3:06 UTC (permalink / raw
  To: ruby-core

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


https://github.com/ruby/ruby/pull/2419

----------------------------------------
Feature #14643: Remove problematic separator '\0' of Dir.glob and Dir.[]
https://bugs.ruby-lang.org/issues/14643#change-81319

* Author: usa (Usaku NAKAMURA)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
`Dir.glob` and `Dir.[]` accepts `'\0'` separated string as the parameter,
but this feature is very problematic.
Shouldn't we remove this feature for Ruby3 ?



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

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

end of thread, other threads:[~2019-09-02  3:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-14643.20180329035217@ruby-lang.org>
2018-03-29  3:52 ` [ruby-core:86377] [Ruby trunk Feature#14643] Remove problematic separator '\0' of Dir.glob and Dir.[] usa
2018-03-30 11:13 ` [ruby-core:86404] " shevegen
2018-03-30 13:28 ` [ruby-core:86405] " nobu
2018-03-30 13:39 ` [ruby-core:86406] " nobu
2018-04-19  6:55 ` [ruby-core:86591] " matz
2019-09-02  0:30 ` [ruby-core:94708] [Ruby master " mame
2019-09-02  3:06 ` [ruby-core:94709] " nobu

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