Skip to content

path: fix win32.isAbsolute()#6028

Closed
mscdex wants to merge 1 commit into
nodejs:masterfrom
mscdex:path-fix-win32-isabsolute
Closed

path: fix win32.isAbsolute()#6028
mscdex wants to merge 1 commit into
nodejs:masterfrom
mscdex:path-fix-win32-isabsolute

Conversation

@mscdex

@mscdex mscdex commented Apr 3, 2016

Copy link
Copy Markdown
Contributor

Pull Request check-list

  • Does make -j8 test (UNIX) or vcbuild test nosign (Windows) pass with
    this change (including linting)?
  • Is the commit message formatted according to CONTRIBUTING.md?
  • If this change fixes a bug (or a performance problem), is a regression
    test (or a benchmark) included?

Affected core subsystem(s)

  • path

Description of change

Fixes: #6027

@mscdex mscdex added windows Issues and PRs related to the Windows platform. path Issues and PRs related to the path subsystem. labels Apr 3, 2016
@mscdex

mscdex commented Apr 3, 2016

Copy link
Copy Markdown
Contributor Author

@benjamingr

Copy link
Copy Markdown
Member

Here are some relevant unit tests for checking if a path is absolute in win32

https://github.com/pmfsampaio/NETMF-LPC/blob/master/MicroFrameworkPK_v4_2/Test/Platform/Tests/CLR/System/IO/Path/IsPathRooted.cs

We should port some/all of them

Comment thread lib/path.js
}
}
} else if (code === 47/*/*/ || code === 92/*\*/) {
if (code === 47/*/*/ || code === 92/*\*/) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is much simpler than the old code - any idea why it was so long and what purpose the checks served?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall offhand, probably just a misinterpretation of the old regexp.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, the new version is correct on its own - the old one is just weird.

@mscdex

mscdex commented Apr 3, 2016

Copy link
Copy Markdown
Contributor Author

Here are some relevant unit tests for checking if a path is absolute in win32

https://github.com/pmfsampaio/NETMF-LPC/blob/master/MicroFrameworkPK_v4_2/Test/Platform/Tests/CLR/System/IO/Path/IsPathRooted.cs

We should port some/all of them

@benjamingr We already cover those more or less, especially so with the test case additions provided by this PR.

@benjamingr

Copy link
Copy Markdown
Member

Any particular reason the code between resolve and normalize is so duplicated?

Unrelated to this PR, but I want to know if there is a specific reason to it.

LGTM + asked for some clarifications.

@mscdex

mscdex commented Apr 3, 2016

Copy link
Copy Markdown
Contributor Author

@benjamingr I don't recall if it was performance reasons or what. If someone wants to try factoring that out and checking the performance differences, go for it :-). However I suspect that a helper function containing that factored out portion wouldn't be inlined (if for no reason other than code size), which would cause a performance regression to some degree.

@jasnell

jasnell commented Apr 4, 2016

Copy link
Copy Markdown
Member

@mscdex ... can you add a bit more explanation to the commit log? Otherwise LGTM

This commit fixes an inconsistency in absolute path checking compared
to the absolute path detection used by the other path.win32 functions.

Fixes: nodejs#6027
PR-URL: nodejs#6028
@mscdex mscdex force-pushed the path-fix-win32-isabsolute branch from d35449c to 45a960e Compare April 4, 2016 01:41
@mscdex

mscdex commented Apr 4, 2016

Copy link
Copy Markdown
Contributor Author

@jasnell Updated

@jasnell

jasnell commented Apr 4, 2016

Copy link
Copy Markdown
Member

Thanks! LGTM!

jasnell pushed a commit that referenced this pull request Apr 4, 2016
This commit fixes an inconsistency in absolute path checking compared
to the absolute path detection used by the other path.win32 functions.

Fixes: #6027
PR-URL: #6028
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell

jasnell commented Apr 4, 2016

Copy link
Copy Markdown
Member

Landed in 3072546

@MylesBorins

Copy link
Copy Markdown
Contributor

@mscdex @jasnell should we back port the test?

edit: it currently passes fwiw

@mscdex

mscdex commented Apr 4, 2016

Copy link
Copy Markdown
Contributor Author

@thealphanerd AFAIK backporting the tests should be fine

@jasnell

jasnell commented Apr 4, 2016

Copy link
Copy Markdown
Member

+1 to backporting the tests

@mscdex mscdex deleted the path-fix-win32-isabsolute branch April 4, 2016 21:56
MylesBorins pushed a commit to MylesBorins/node that referenced this pull request Apr 4, 2016
Adds test cases to ensure win32.isAbsolute is consistent.

This is a backport from 3072546

ref: nodejs#6028
MylesBorins pushed a commit that referenced this pull request Apr 5, 2016
This commit fixes an inconsistency in absolute path checking compared
to the absolute path detection used by the other path.win32 functions.

Fixes: #6027
PR-URL: #6028
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Apr 5, 2016
Notable changes:

http:
  * Enclose IPv6 Host header in square brackets. This will enable
  proper seperation of the host adress from any port reference
  (Mihai Potra) #5314
path:
  * Make win32.isAbsolute more consistent (Brian White)
  #6028
This was referenced Apr 5, 2016
MylesBorins pushed a commit that referenced this pull request Apr 5, 2016
Notable changes:

http:
  * Enclose IPv6 Host header in square brackets. This will enable
  proper seperation of the host adress from any port reference
  (Mihai Potra) #5314

path:
  * Make win32.isAbsolute more consistent (Brian White)
  #6028

PR-URL: #6060
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
MylesBorins pushed a commit that referenced this pull request Apr 5, 2016
Notable changes:

http:
  * Enclose IPv6 Host header in square brackets. This will enable
  proper seperation of the host adress from any port reference
  (Mihai Potra) #5314

path:
  * Make win32.isAbsolute more consistent (Brian White)
  #6028

PR-URL: #6060
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
jasnell pushed a commit that referenced this pull request Apr 8, 2016
Adds test cases to ensure win32.isAbsolute is consistent.

This is a backport from 3072546

Refs: #6028
PR-URL: #6043
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Roman Reiss <me@silverwind.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

path Issues and PRs related to the path subsystem. windows Issues and PRs related to the Windows platform.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

path.isAbsolute wrong output

4 participants