https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112012-11-17T03:32:19ZRuby Issue Tracking SystemRuby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=329882012-11-17T03:32:19Zmdube@arcane-technologies.com (Martin Dubé)
<ul></ul><p>ruby 1.9.3p194 (2012-04-20) [i386-mingw32] is working fine:</p>
<p>irb(main):002:0> File.expand_path("./<em>", "c:/temp")<br>
=> "c:/temp/</em>"</p> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=329912012-11-17T06:32:01Zluislavena (Luis Lavena)luislavena@gmail.com
<ul><li><strong>Category</strong> set to <i>core</i></li><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>h.shirosaki (Hiroshi Shirosaki)</i></li></ul><p>Martin,</p>
<p>Can you confirm if this happen with Ruby 2.0? (trunk, you can get automated builds from RubyInstaller CI)</p>
<p>Shirosaki-san,</p>
<p>Seems that globing has been enabled?</p> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=329922012-11-17T07:09:30Zluislavena (Luis Lavena)luislavena@gmail.com
<ul><li><strong>Assignee</strong> changed from <i>h.shirosaki (Hiroshi Shirosaki)</i> to <i>luislavena (Luis Lavena)</i></li><li><strong>Priority</strong> changed from <i>Normal</i> to <i>5</i></li><li><strong>Target version</strong> set to <i>2.0.0</i></li></ul><p>=begin<br>
I can confirm this happens on both 1.9.3-p327 and trunk.</p>
<p>Problem seems to be related to replace_to_long_name which attempts to expand the last part of the path using FindFirstFileW (globing), but is ignoring that it includes "*" in the filename.</p>
<p>I'm checking this and adding a test for this scenario.</p>
<p>Thank you for your report.<br>
=end</p> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=329932012-11-17T07:19:04Zmdube@arcane-technologies.com (Martin Dubé)
<ul></ul><p>luislavena (Luis Lavena) wrote:</p>
<blockquote>
<p>Martin,</p>
<p>Can you confirm if this happen with Ruby 2.0? (trunk, you can get automated builds from RubyInstaller CI)</p>
<p>Shirosaki-san,</p>
<p>Seems that globing has been enabled?</p>
</blockquote>
<p>Yes, same problem with r37691:</p>
<p>C:\ruby-2.0.0-r37691-i386-mingw32\bin>irb.bat<br>
irb(main):001:0> File.expand_path("./*", "c:/")<br>
=> "c:/$RECYCLE.BIN"<br>
irb(main):002:0></p> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=329942012-11-17T07:22:02Zluislavena (Luis Lavena)luislavena@gmail.com
<ul></ul><p>Martin,</p>
<p>I'm adding tests for this, do you have any other scenario that is failing and you want to report?</p>
<p>It will be great if we can cover all those by a single commit.</p>
<p>Thank you.</p> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=329952012-11-17T07:31:23Zmdube@arcane-technologies.com (Martin Dubé)
<ul></ul><p>=begin<br>
No other scenario. Caught that bug trying to install a plugin to redmine 2.1.2 with ruby 1.9.3p327</p>
<p>Redmine then attempt to add plugins routes with the following code:</p>
<p>(({Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|}))</p>
<p>Which end up enumerating only the "." directory instead of all subdirectories in ./plugins<br>
=end</p> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=329962012-11-17T07:43:23Zluislavena (Luis Lavena)luislavena@gmail.com
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r37692.<br>
Martin, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<p>skip long name conversion if last character is a wildcard one</p>
<ul>
<li>
<p>win32/file.c (replace_to_long_name): skip automatic path expansion<br>
when wildcard character is used. <a href="/issues/7374">[ruby-core:49451]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: File.expand_path resolving to first file/dir instead of absolute path (Closed)" href="https://redmine.ruby-lang.org/issues/7374">#7374</a>]</p>
</li>
<li>
<p>test/ruby/test_file_exhaustive.rb: add a test for above.</p>
</li>
</ul> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=329972012-11-17T07:45:18Zluislavena (Luis Lavena)luislavena@gmail.com
<ul></ul><p>Martin,</p>
<p>I've committed some tests and a fix for this.</p>
<p>Automated builds will kick in soon, please check RubyInstaller CI to download binary packages.</p>
<p>I'll request a backport once I get confirmation this works on your end.</p> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=330002012-11-17T10:05:16Zh.shirosaki (Hiroshi Shirosaki)h.shirosaki@gmail.com
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Assigned</i></li></ul><p>It seems if the last part of the path contains * or ?, FindFirstFileW should not be used since FindFirstFileW expands wildcard.</p>
<p>Examples:<br>
File.expand_path("foo/ab*c")<br>
File.expand_path("foo/ab?c")</p>
<p>Code in file.c uses strpbrk(s, "*?") for that.<br>
<a href="https://github.com/ruby/ruby/blob/trunk/file.c#L3141" class="external">https://github.com/ruby/ruby/blob/trunk/file.c#L3141</a></p> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=330212012-11-17T21:33:03Zluislavena (Luis Lavena)luislavena@gmail.com
<ul><li><strong>% Done</strong> changed from <i>100</i> to <i>50</i></li></ul><p>h.shirosaki (Hiroshi Shirosaki) wrote:</p>
<blockquote>
<p>It seems if the last part of the path contains * or ?, FindFirstFileW should not be used since FindFirstFileW expands wildcard.</p>
</blockquote>
<p>Thank you Shirosaki, I did a naive fix and completely missed "?" character.</p>
<p>Will modify replace_to_long_name to check for this.</p> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=330222012-11-17T21:46:19Zluislavena (Luis Lavena)luislavena@gmail.com
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>50</i> to <i>100</i></li></ul><p>This issue was solved with changeset r37700.<br>
Martin, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<p>Skip path expansion for all wildcard characters</p>
<ul>
<li>
<p>win32/file.c (replace_to_long_name): skip expansion for all wildcard<br>
characters.<br>
<a href="/issues/7374">[ruby-core:49451]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: File.expand_path resolving to first file/dir instead of absolute path (Closed)" href="https://redmine.ruby-lang.org/issues/7374">#7374</a>]</p>
</li>
<li>
<p>test/ruby/test_file_exhaustive.rb: add more assertions to test.</p>
</li>
</ul> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=330242012-11-18T00:55:29Zluislavena (Luis Lavena)luislavena@gmail.com
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Assigned</i></li><li><strong>% Done</strong> changed from <i>100</i> to <i>90</i></li></ul><p>=begin<br>
Sorry for the noise, but seems I've a Webrick failure caused by this that didn't catch when sent r37700 in.</p>
<p>test_short_filename(WEBrick::TestFileHandler) [C:/Users/Worker/Jenkins/workspace/ruby-trunk-x86-build/test/webrick/test_filehandler.rb:240]:<br>
webrick log start:<br>
[2012-11-17 12:49:00] INFO WEBrick 1.3.1<br>
[2012-11-17 12:49:00] INFO ruby 2.0.0 (2012-11-17) [i386-mingw32]<br>
[2012-11-17 12:49:00] INFO WEBrick::HTTPServer#start: pid=14444 port=62527</p>
<p>[2012-11-17 12:49:00] WARN the request refers nondisclosure name <code>.htaccess'. [2012-11-17 12:49:00] ERROR </code>/.htaccess' not found.</p>
<p>webrick log end.<br>
<"404"> expected but was<br>
<"200">.</p>
<p>Looking into this right now.<br>
=end</p> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=330252012-11-18T02:53:24Zluislavena (Luis Lavena)luislavena@gmail.com
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>90</i> to <i>100</i></li></ul><p>This issue was solved with changeset r37706.<br>
Martin, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<p>Swap logic around wildcard character detection</p>
<ul>
<li>win32/file.c (replace_to_long_name): correct logic around wildcard<br>
characters detection and ensure wide-chars are used as pattern.<br>
<a href="/issues/7374">[ruby-core:49451]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: File.expand_path resolving to first file/dir instead of absolute path (Closed)" href="https://redmine.ruby-lang.org/issues/7374">#7374</a>]</li>
</ul> Ruby master - Bug #7374: File.expand_path resolving to first file/dir instead of absolute pathhttps://redmine.ruby-lang.org/issues/7374?journal_id=330262012-11-18T03:04:01Zluislavena (Luis Lavena)luislavena@gmail.com
<ul></ul><p>Martin, Hiroshi,</p>
<p>This should be finally fixed by r37706, sorry for all the inconveniences!</p>
<p>(note to myself: don't commit to Ruby on during night, even less on friday).</p>