-
Couldn't load subscription status.
- Fork 3.4k
Fix path resolution for symlinks #23072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If `/a/link` is a symlink to directory `/b/c` then `/a/link/..` should be resolved to `/b/c/..` which is `/b`. Currently, we cancel out `link/..` to get `/a`. The problem is that we apply `PATH_FS.resolve` and `PATH_FS.normalize` to paths. These functions cancel `..` incorrectly. This at least partially handles the situation. `lookupPath` is modified to avoid calls that call `PATH_FS.normalize()`. We check that `mkdir`, `open`, and `stat` now work correctly.
src/library_syscall.js
Outdated
| if (!dir.endsWith("/")) { | ||
| dir += "/" | ||
| } | ||
| return dir + path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this different to the old code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
join2 calls normalize which will incorrectly replace /a/b/.. with /a.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just return dir + '/' + path ? Or return '${dir}/${path}'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'll probably work fine, I put it in and will let the CI say.
If `/a/link` is a symlink to directory `/b/c` then `/a/link/..` should be resolved to `/b/c/..` which is `/b`. Currently, we cancel out `link/..` to get `/a`. The problem is that we apply `PATH_FS.resolve` and `PATH_FS.normalize` to paths. These functions cancel `..` incorrectly. This at least partially handles the situation. `lookupPath` is modified to avoid calls that call `PATH_FS.normalize()`. We check that `mkdir`, `open`, `stat`, `truncate`, and `chmod` now work correctly.
If
/a/linkis a symlink to directory/b/cthen/a/link/..should be resolved to/b/c/..which is/b. Currently, we cancel outlink/..to get/a. The problem is that we applyPATH_FS.resolveandPATH_FS.normalizeto paths. These functions cancel..incorrectly.This at least partially handles the situation.
lookupPathis modified to avoid calls that callPATH_FS.normalize(). We check thatmkdir,open,stat,truncate, andchmodnow work correctly.