Skip to content
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

Fix for path.resolve containing relative path to another drive in windows #57

Closed
wants to merge 1 commit into from

Conversation

ankurp
Copy link

@ankurp ankurp commented Dec 4, 2014

Fixes #50

Issue can be reproduced by running path.resolve in Windows as such path.resolve('C:/some/random/path', '../../../../../D:/another/random/path'); This outputs c:\D:\another\random\path where d: drive is not considered absolute.

@rvagg rvagg force-pushed the v0.12 branch 4 times, most recently from d7e65ff to 185d11c Compare December 4, 2014 10:21
@rvagg
Copy link
Member

rvagg commented Dec 4, 2014

thanks @ankurp, could you rebase this off v0.12 please, you have some additional commit noise in here from 8868378 which makes this hard to review, aim for just showing your commits (and before it's merged it needs to be just one commit but you can squash later)

@ankurp
Copy link
Author

ankurp commented Dec 4, 2014

I just added upstream git remote add upstream https://github.com/iojs/io.js and did a pull from git pull upstream v0.12 and merged

@ankurp
Copy link
Author

ankurp commented Dec 4, 2014

Seems like other people's commits got included. Is v0.12 the branch to pull from or master?

@indutny
Copy link
Member

indutny commented Dec 4, 2014

ok, you totally borked it out :)

git fetch upstream
git reset --hard upstream/v0.12
git cherry-pick 25e68db 1652761 1e42c96 143a03b
git push -f origin v0.12

Also I would recommend you to use feature branches next time, to ensure that this things won't happen. And do git fetch upstream && git rebase upstream/v0.12 or git pull --rebase upstream v0.12 instead of just git pull.

@ankurp
Copy link
Author

ankurp commented Dec 4, 2014

Will do

@ankurp
Copy link
Author

ankurp commented Dec 5, 2014

Done cherry picked only my changes.

@ankurp
Copy link
Author

ankurp commented Dec 6, 2014

Can we merge this. I thought this fork was more active than nodejs

@bnoordhuis
Copy link
Member

@ankurp This needs a review from a Windows developer, maybe @seishun or @piscisaureus.

To expedient matters, can you squash the commits and write a nice commit log? See CONTRIBUTING.md for an example. Thanks.

@seishun
Copy link
Contributor

seishun commented Dec 6, 2014

@ankurp '../../../../../D:/another/random/path' doesn't look like a valid path to me. Can you name an example where this works as you would expect?

@ankurp
Copy link
Author

ankurp commented Dec 6, 2014

I am squashing the commits. I found this bug when generating sourcemaps for a web project and the files being imported in sass were on a different Windows drive. If you do a path.relative from one drive to another it will go up using ../ until it reaches My Computer and then go to the letter drive.

@ankurp
Copy link
Author

ankurp commented Dec 6, 2014

@seishun Try this please in io.js path.relative("c:/some/dir", "d:/some/fold") and you will get ../../../d:/some/fold

paths starting with relative path to another drive for example `../../d:/some/dir/` are not resolved correctly. This regex update fixes it.

Adding and updating tests along with the fix.
@seishun
Copy link
Contributor

seishun commented Dec 6, 2014

This is a path.relative bug if anything. Relative path across drives doesn't make sense. See for example PathRelativePathTo: "On the other hand, "c:\FolderA\FolderB" and "a:\FolderA\FolderD do not share a common prefix, and the function will fail.".

@ankurp
Copy link
Author

ankurp commented Dec 6, 2014

@seishun The relative path is correct as in the drives are mounted at the root in Windows. You can follow along the relative path and get to that folder in other drive. I have also squashed the commit and updated the PR.

@seishun
Copy link
Contributor

seishun commented Dec 6, 2014

the drives are mounted at the root in Windows.

There is no single "root" in Windows. My Computer is purely a Windows Explorer concept.

You can follow along the relative path and get to that folder in other drive.

Actually no, cd won't even let you change drives without a /D switch. cd .. at the root of a drive does nothing.

@ankurp
Copy link
Author

ankurp commented Dec 6, 2014

Then the fix is to throw an error if someone tries to do relative path across drives?

@seishun
Copy link
Contributor

seishun commented Dec 6, 2014

That sounds sane to me. It's a good translation of returning FALSE from PathRelativePathTo.

@ankurp
Copy link
Author

ankurp commented Dec 6, 2014

Ok let me change the PR then.

@piscisaureus
Copy link
Contributor

-1.

..\..\c:\etc\bla is always in invalid path.
If a path operation turns an invalid path into a valid path, that's a disaster or security issue waiting to happen.
I think "garbage in, garbage out" is wildly more preferrable.

@ankurp
Copy link
Author

ankurp commented Dec 8, 2014

OK then I will throw an exception if there are ../ in the path to another lettered drive.

dacappo added a commit to SAP-archive/node-rasp that referenced this pull request Nov 29, 2018
* [GitHub] Fork specific PR template

* [GitHub] Check for SemVer and Windows test-taint goal
dacappo added a commit to SAP-archive/node-rasp that referenced this pull request Dec 3, 2018
* [GitHub] Fork specific PR template

* [GitHub] Check for SemVer and Windows test-taint goal
dacappo added a commit to SAP-archive/node-rasp that referenced this pull request Jan 24, 2019
* [GitHub] Fork specific PR template

* [GitHub] Check for SemVer and Windows test-taint goal
targos added a commit to targos/node that referenced this pull request Apr 17, 2021
Original commit message:

    [bigint] Fix possibly-uninitialized leading digit on right shift

    (cherry picked from commit e82a3b4d47a93ab64f07d8c03e3cd17b6b961c3f)

    (cherry picked from commit 1162c460dee4218abd798b51b88926aef5c8bd61)

    No-Try: true
    No-Presubmit: true
    No-Tree-Checks: true
    Fixed: chromium:1151890
    Change-Id: I26f5c76494a9ff3f5a141f381e1c9a543e368571
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2561618
    Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
    Commit-Queue: Georg Neis <neis@chromium.org>
    Reviewed-by: Georg Neis <neis@chromium.org>
    Cr-Original-Original-Commit-Position: refs/heads/master@{#71422}
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2565245
    Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Original-Commit-Position: refs/branch-heads/8.7@{nodejs#57}
    Cr-Original-Branched-From: 0d81cd72688512abcbe1601015baee390c484a6a-refs/heads/8.7.220@{#1}
    Cr-Original-Branched-From: 942c2ef85caef00fcf02517d049f05e9a3d4b440-refs/heads/master@{#70196}
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2624611
    Commit-Queue: Victor-Gabriel Savu <vsavu@google.com>
    Cr-Commit-Position: refs/branch-heads/8.6@{nodejs#54}
    Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1}
    Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472}

Refs: v8/v8@412ac52
targos added a commit to targos/node that referenced this pull request Apr 27, 2021
Original commit message:

    [bigint] Fix possibly-uninitialized leading digit on right shift

    (cherry picked from commit e82a3b4d47a93ab64f07d8c03e3cd17b6b961c3f)

    (cherry picked from commit 1162c460dee4218abd798b51b88926aef5c8bd61)

    No-Try: true
    No-Presubmit: true
    No-Tree-Checks: true
    Fixed: chromium:1151890
    Change-Id: I26f5c76494a9ff3f5a141f381e1c9a543e368571
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2561618
    Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
    Commit-Queue: Georg Neis <neis@chromium.org>
    Reviewed-by: Georg Neis <neis@chromium.org>
    Cr-Original-Original-Commit-Position: refs/heads/master@{#71422}
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2565245
    Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Original-Commit-Position: refs/branch-heads/8.7@{nodejs#57}
    Cr-Original-Branched-From: 0d81cd72688512abcbe1601015baee390c484a6a-refs/heads/8.7.220@{#1}
    Cr-Original-Branched-From: 942c2ef85caef00fcf02517d049f05e9a3d4b440-refs/heads/master@{#70196}
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2624611
    Commit-Queue: Victor-Gabriel Savu <vsavu@google.com>
    Cr-Commit-Position: refs/branch-heads/8.6@{nodejs#54}
    Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1}
    Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472}

Refs: v8/v8@412ac52
targos added a commit that referenced this pull request Apr 30, 2021
Original commit message:

    [bigint] Fix possibly-uninitialized leading digit on right shift

    (cherry picked from commit e82a3b4d47a93ab64f07d8c03e3cd17b6b961c3f)

    (cherry picked from commit 1162c460dee4218abd798b51b88926aef5c8bd61)

    No-Try: true
    No-Presubmit: true
    No-Tree-Checks: true
    Fixed: chromium:1151890
    Change-Id: I26f5c76494a9ff3f5a141f381e1c9a543e368571
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2561618
    Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
    Commit-Queue: Georg Neis <neis@chromium.org>
    Reviewed-by: Georg Neis <neis@chromium.org>
    Cr-Original-Original-Commit-Position: refs/heads/master@{#71422}
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2565245
    Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Original-Commit-Position: refs/branch-heads/8.7@{#57}
    Cr-Original-Branched-From: 0d81cd72688512abcbe1601015baee390c484a6a-refs/heads/8.7.220@{#1}
    Cr-Original-Branched-From: 942c2ef85caef00fcf02517d049f05e9a3d4b440-refs/heads/master@{#70196}
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2624611
    Commit-Queue: Victor-Gabriel Savu <vsavu@google.com>
    Cr-Commit-Position: refs/branch-heads/8.6@{#54}
    Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1}
    Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472}

Refs: v8/v8@412ac52

PR-URL: #38275
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants