jruby 184.108.40.206-SNAPSHOT (2.5.0) 2018-09-28 8e6904f Java HotSpot(TM) 64-Bit Server VM 25.181-b13 on 1.8.0_181-b13 +jit [linux-x86_64]
The text was updated successfully, but these errors were encountered:
Confirmed locally on master. Note that it works if the
Perhaps a simple issue with normalizing path separators?
Ok so I'm dumping my research since I don't know if I'll fix this over the weekend.
The logic that cleans up this rogue slash is from MRI glob_helper function, which largely has an equivalent in JRuby...except that the logic is ordered somewhat differently.
In MRI, glob_helper scans the whole set of path chunks for magic characters, and then has two separate branches to process them with and without magic. In JRuby, we check each segment for magic characters separately, but when there's no magic we do not process the segment and simply advance.
I think this may be possible to fix by considering backslash characters to be "magic" when escaping is on. I tried adding an "else" branch to the magic check that cleans up slashes, but it appears to break other things and there's a lot of missing logic in that else branch on MRI.
This is a workaround for issues found in jruby#5333. I discovered while researching a fix for that bug that our `glob_helper` appears to be missing "else" logic for the segment processing that handles magic characters and unescaping. Put simply, if there's no magic in the segment it leaves it entirely unprocessed, allowing its contents to just get rolled into the next segment loop (which may or may not also have magic). However this leaves escapes in place. This "fix" basically just omits the magic check for each segment and allows full processing.
This narrows my fix to only fire for segments with magic chars (* and ? and the like) or backslashes in the presence of escaped mode (i.e. not FNM_NOESCAPE). This will slow down the processing of segments that contain only backslash escapes, but they were not processed properly before anyway. Segments without backslashes or magic characters are unaffected. Segments with backslashes and magic characters are unaffected.