Skip to content

Conversation

@danini-the-panini
Copy link
Contributor

@danini-the-panini danini-the-panini commented Dec 21, 2024

  1. Reverts Fix Dir.glob with cases #6681 to resolve Dir[] vs "../../" #8426
  2. Ignore passed-in FNM_CASEFOLD option to Dir.glob, to match MRI.
  3. Modify has_magic to return an enum instead of a boolean.
    This distinguishes paths with "alpha" chars, which get treated as magical in case-insensitive filesystems.
    Forces each path segment to be fetched from the filesystem in order to do a fnmatch, even if it doesn't contain any magic glob patterns.
  4. Maintain SKIPDOT for ALPHA-magic path segments, to ensure FNM_DOTMATCH functionality matches MRI.
  5. Handle schema in glob patterns

@enebo enebo added this to the JRuby 9.4.10.0 milestone Dec 21, 2024
@headius
Copy link
Member

headius commented Jan 15, 2025

I am reluctant to revert that fix without some input from @edipofederle on what exactly it fixed. Punting to 9.4.11.0 so we can discuss further.

@danini-the-panini
Copy link
Contributor Author

Looking at the logic they added, it just queried the filesystem for the actual path and replaced the glob result with that, taking into account paths starting with ./. However, this does not take into account any .. in the path, which causes massive problems when glob patterns include it. I'm very pro reverting it until a better fix comes around, since I think preserving case in a case-insensitive filesystem is less important than globbing actually working.

The idea wasn't to merely just revert the change, though. I'm also still trying to find a way to do it on the fly, however it's proving to be quite tricky since the glob logic is so convoluted. I may still just try rework the original fix to better take into account .. and . in the glob pattern.

@danini-the-panini danini-the-panini marked this pull request as ready for review January 16, 2025 18:32
@danini-the-panini
Copy link
Contributor Author

@headius @enebo how are we feeling about this?

Comment on lines -810 to +831
final int end = begin + path.getRealSize();
final int end = begin + path.length();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure if this changes anything. looks like length just returns realSize :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danini-the-panini length() is there to satisfy Java CharSequence. It is fine to leave it since it will always match byte length but it is a weird method since it implies it should return char length.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have discussed in the past modifying the CharSequence methods of ByteList to actually work against the contained characters rather than just the bytes but at this point it's so entrenched we'd have to break the world to do it. I think this is fine.

Copy link
Member

@enebo enebo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is impossible to trace through this and know you are prepending scheme in all cases but that is the nature of this code. It is very complicated.

I see no new tests but I do wonder if you noticed any cases which we are lacking coverage?

@danini-the-panini
Copy link
Contributor Author

@enebo there aren't really any new test cases, the case I sensitive one was enabled by the previous fix which I reverted. The only other thing to test would be the ../ case but it's quite niche.

Copy link
Member

@headius headius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complicated logic being patched here but I like the changes and the move to an enum for the three-mode magic glob behavior. Minor recommendations to address but otherwise this is good to go.

Comment on lines -810 to +831
final int end = begin + path.getRealSize();
final int end = begin + path.length();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have discussed in the past modifying the CharSequence methods of ByteList to actually work against the contained characters rather than just the bytes but at this point it's so entrenched we'd have to break the world to do it. I think this is fine.

@headius
Copy link
Member

headius commented Jan 28, 2025

I approve of merging this for 9.4.11.0, or punting to 9.4.12.0.

@enebo enebo merged commit a73dd28 into jruby:master Feb 11, 2025
95 checks passed
@danini-the-panini danini-the-panini deleted the ds-8426-fix-glob branch February 11, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dir[] vs "../../"

3 participants