Fix bug in symlink traversal with indirect targets#1084
Closed
robhogan wants to merge 1 commit intofacebook:mainfrom
Closed
Fix bug in symlink traversal with indirect targets#1084robhogan wants to merge 1 commit intofacebook:mainfrom
robhogan wants to merge 1 commit intofacebook:mainfrom
Conversation
Summary:
Fixes a bug where symlinks beginning with indirections (`../`) may fail to traverse in some `projectRoot` / `watchFolders` configurations.
This occurs due to incomplete "normalisation" of a symlink target in `metro-file-map`, relative to the project root. Given a project root of `/project` and a symlink `/project/src/link-to-foo -> ../../project/foo.js`, we would normalise the target to `../project/foo.js` rather than simply `foo.js` - we were not taking into account that further normalisation could be possible after joining with `projectRoot`.
"Normal" paths are defined as being *fully* normalised relative to the project root. The unnecessary indirection out and back into the project root fails because `TreeFS` is a DAG, and internally there is no entry for `rootNode.get('..').get('project')` - this would be a cycle back to `rootNode`.
Changelog:
```
* **[Fix]:** Symlinks with indirections may not be resolvable
```
Differential Revision: D49323614
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D49323614 |
Contributor
|
This pull request has been merged in 6f3f7e6. |
robhogan
added a commit
that referenced
this pull request
Jan 9, 2024
Summary: Pull Request resolved: #1084 Fixes a bug where symlinks beginning with indirections (`../`) may fail to traverse in some `projectRoot` / `watchFolders` configurations. This occurs due to incomplete "normalisation" of a symlink target in `metro-file-map`, relative to the project root. Given a project root of `/project` and a symlink `/project/src/link-to-foo -> ../../project/foo.js`, we would normalise the target to `../project/foo.js` rather than simply `foo.js` - we were not taking into account that further normalisation could be possible after joining with `projectRoot`. "Normal" paths are defined as being *fully* normalised relative to the project root. The unnecessary indirection out and back into the project root fails because `TreeFS` is a DAG, and internally there is no entry for `rootNode.get('..').get('project')` - this would be a cycle back to `rootNode`. Changelog: ``` * **[Fix]:** Symlinks with indirections may not be resolvable ``` Reviewed By: yungsters Differential Revision: D49323614 fbshipit-source-id: e01a10a0455b0af22ebc3cdd7c34ca8fd888d0f4
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Fixes a bug where symlinks beginning with indirections (
../) may fail to traverse in someprojectRoot/watchFoldersconfigurations.This occurs due to incomplete "normalisation" of a symlink target in
metro-file-map, relative to the project root. Given a project root of/projectand a symlink/project/src/link-to-foo -> ../../project/foo.js, we would normalise the target to../project/foo.jsrather than simplyfoo.js- we were not taking into account that further normalisation could be possible after joining withprojectRoot."Normal" paths are defined as being fully normalised relative to the project root. The unnecessary indirection out and back into the project root fails because
TreeFSis a DAG, and internally there is no entry forrootNode.get('..').get('project')- this would be a cycle back torootNode.Changelog:
Differential Revision: D49323614