fix(metro-file-map): Fix Windows cross-device path resolution#1711
fix(metro-file-map): Fix Windows cross-device path resolution#1711kitten wants to merge 10 commits into
Conversation
# Why Reported at react/metro#1696. This PR is being upstreamed at: react/metro#1711 The intention in Metro is that cross-device paths are represented as relative normal paths. If the root dir is at `C:\project` then a cross-device normal path at `D:\temp` is represented as `..\..\D:\temp`. This assumption is broken in several places, like `normalToAbsolute` printing, leading to `C:\D:\` paths that are invalid. # How - Fix `normalToAbsolute` not cutting off cross-device absolute paths - Fix `resolveSymlinkToNormal` cutting off trailing slash for absolute Windows device paths - Prevent double slash when appending normal path to root `C:\` path - Prevent `TreeFS#remove` from re-normalizing internally built paths, which can lead to excessively clamped paths - Adjust relative root maximum depth for Windows (remove `-1` adjustment for Windows) # Test Plan - Represented in unit test changes - **Note:** Invalid unit tests have been removed for paths that rise above the filesystem root # Checklist <!-- Please check the appropriate items below if they apply to your diff. --> - [x] I added a `changelog.md` entry and rebuilt the package sources according to [this short guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
|
@CalixTang has imported this pull request. If you are a Meta employee, you can view this in D104700077. |
|
Thanks again for looking at this!
This is very edge-casey but the behaviour of https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13
In particular, if you create a symlink with the target |
|
(Also, nit: device != drive. These are cross-drive paths) |
|
interesting! that's an easy fix, but requires us to use |
Co-authored-by: Rob Hogan <2590098+robhogan@users.noreply.github.com>
ab79459 to
9884f2a
Compare
|
@CalixTang merged this pull request in 6e6b52c. |
…-up) (#45687) # Why Follow-up to #45648 to address review feedback at react/metro#1711 (ongoing) # How - Fix `'..'` at root handling to align with Metro # Test Plan - Covered by unit test changes # Checklist <!-- Please check the appropriate items below if they apply to your diff. --> - [x] I added a `changelog.md` entry and rebuilt the package sources according to [this short guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
Summary
Related PR for
expo/expofork: expo/expo#45648Supersedes #1696
Cross-device path normals are intended to be relative paths from the rootDir. If the rootDir is at
C:\projectthen a cross-device normal path atD:\tempis represented as..\..\D:\temp. This assumption is broken in several places, likenormalToAbsoluteprinting, leading toC:\D:\paths that are invalid.Changelog: [Fix] Fix Windows path handling for cross-drive paths
Test plan