node icon indicating copy to clipboard operation
node copied to clipboard

path: fix win32.relative() for some Unicode paths

Open mscdex opened this issue 5 years ago • 26 comments

Fixes: https://github.com/nodejs/node/issues/27534

This is an alternative to https://github.com/nodejs/node/pull/27644 that avoids any performance regressions in cases where lowercased versions of paths do not differ in length to the original.

The only minor issue (in practice it may not really matter) is that return values are always returned normalized using canonical composition if the lowercased version differed in length to the original, which may be unexpected if you passed in a path that was normalized using canonical decomposition for example.

Checklist
  • [x] make -j4 test (UNIX), or vcbuild test (Windows) passes
  • [x] tests and/or benchmarks are included
  • [x] commit message follows commit guidelines

mscdex avatar May 12 '19 20:05 mscdex

Lite-CI: https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/3494

nodejs-github-bot avatar May 12 '19 20:05 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/23069/

nodejs-github-bot avatar May 12 '19 20:05 nodejs-github-bot

Perhaps for builds without intl we could utilize a polyfill, such as unorm.

mscdex avatar May 12 '19 21:05 mscdex

Alternatively we could ignore additional code points and only compare base symbols, but I'm not sure if that's how Windows/NTFS/etc. compares characters in paths.

mscdex avatar May 12 '19 21:05 mscdex

@BridgeAR do you have a specific test case in mind?

mscdex avatar May 22 '19 04:05 mscdex

@mscdex sorry I made a mistake while looking at this earlier. It should indeed work properly in all cases (if intl is available). About the polyfill: we could also change the algorithm itself to better reflect what we want in case the length is not identical. Using that would also prevent the edge case mentioned above.

One of these implementations could e.g. look like: "loop over the original first argument and slice out parts, lowercase them and compare them with the other side in case you find a slash." That should be almost as fast as the generic implementation.

BridgeAR avatar May 22 '19 09:05 BridgeAR

ping @mscdex @BridgeAR @jdalton is this ready basically but needs reviews?

lundibundi avatar Aug 25 '20 19:08 lundibundi

@lundibundi I guess?

mscdex avatar Aug 25 '20 20:08 mscdex

@jdalton I think your request changes can now be dismissed?

ping @nodejs/path

lundibundi avatar Sep 02 '20 12:09 lundibundi

CI: https://ci.nodejs.org/job/node-test-pull-request/33003/

nodejs-github-bot avatar Sep 02 '20 12:09 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/33075/

nodejs-github-bot avatar Sep 06 '20 09:09 nodejs-github-bot

Seems like it would fix a crash in my app for users with İ in the file path: https://github.com/whyboris/Video-Hub-App/issues/533#issuecomment-707890842

whyboris avatar Oct 13 '20 17:10 whyboris

CI: https://ci.nodejs.org/job/node-test-pull-request/33726/

nodejs-github-bot avatar Oct 19 '20 17:10 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/33737/

nodejs-github-bot avatar Oct 19 '20 22:10 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/33747/

nodejs-github-bot avatar Oct 20 '20 07:10 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/33749/

nodejs-github-bot avatar Oct 20 '20 08:10 nodejs-github-bot

@mscdex The CI is failing consistently on very specific jobs, I'm not sure if this needs action or is just flaky CI.

aduh95 avatar Oct 20 '20 08:10 aduh95

CI: https://ci.nodejs.org/job/node-test-pull-request/33803/

nodejs-github-bot avatar Oct 22 '20 18:10 nodejs-github-bot

@aduh95 The error in the intl-less build environment makes sense. I don't think we came to a consensus about how to handle that situation. I suggested using a pure JS polyfill for a consistent experience whether intl is available or not. @BridgeAR had a separate suggestion. Maybe someone else has additional input into this or is ok with one of these solutions?

mscdex avatar Oct 22 '20 22:10 mscdex

This issue/PR was marked as stalled, it will be automatically closed in 30 days. If it should remain open, please leave a comment explaining why it should remain open.

github-actions[bot] avatar Dec 15 '20 21:12 github-actions[bot]

@mscdex -- could you resolve the conflicting files (currently only lib/path.js)

@jdalton -- is there any reason to delay merging after the merge conflicts are resolved? 🙏

whyboris avatar Dec 15 '20 21:12 whyboris

@whyboris I'll be happy to cherry-pick @mscdex's commit, resolve the conflicts and create another PR if they're not available at the moment.

I've been using a custom-built (using #27644) node for almost two years and I really want this officially fixed. 😐

monoblaine avatar Jan 30 '21 17:01 monoblaine

@monoblaine the issue about what to do about intl-less node builds hasn't been resolved yet, so resolving merge conflicts isn't worthwhile at this point

mscdex avatar Jan 30 '21 21:01 mscdex

Oh, NOW I understand the problem here. (It took only two years)

A note to my future self and other fast learners like me:

  • Node uses ICU to implement internationalization support.
  • This significantly increases the file size.
  • Therefore node has the option to make a build wihout intl support.
  • The changes introduced in this PR is dependent on intl support's existence and that's a problem. (An alternative solution is proposed but not yet discussed.)

monoblaine avatar Feb 07 '21 18:02 monoblaine

@mscdex is this PR still something that can/should land? Is there anything that's currently blocking?

bnb avatar Jan 11 '22 20:01 bnb

@bnb

is this PR still something that can/should land?

I'm not really the one to ask, I was just providing an alternative solution to an issue.

Is there anything that's currently blocking?

https://github.com/nodejs/node/pull/27662#issuecomment-770283526

mscdex avatar Jan 11 '22 22:01 mscdex

Superseded by another PR

BridgeAR avatar Aug 06 '24 09:08 BridgeAR