Skip to content

Commit

Permalink
Fixed Windows Traversal Root Path (#68)
Browse files Browse the repository at this point in the history
Made Traversal Root Check Platform Agnostic
  • Loading branch information
ObliviousHarmony authored Apr 19, 2023
1 parent 53cd29c commit 7434359
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Detect `phpcs.xml.dist` and `.phpcs.xml.dist` configuration files.
- Detection of filesystem root when traversing paths on Windows.

## [2.0.0] - 2023-04-13
### Added
Expand Down
4 changes: 4 additions & 0 deletions src/__mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Uri.joinPath = jest
uriSegments.push(seg);
}

if (uriSegments.length <= 0) {
uriSegments.push(process.platform === 'win32' ? 'c:/' : '/');
}

const path = uriSegments.join('/');

const created = {
Expand Down
5 changes: 2 additions & 3 deletions src/services/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,8 @@ export class Configuration {
return false;
}

// Only traverse as far as the workspace folder. We don't
// want to accidentally check folders outside of it.
while (folder.path !== '/') {
// When we reach the filesystem root we have no reason to keep searching.
while (!folder.path.match(/^(?:[a-z]:)?\/$/i)) {
// When the request is cancelled, we don't want to keep looking.
if (cancellationToken?.isCancellationRequested) {
throw new CancellationError();
Expand Down

0 comments on commit 7434359

Please sign in to comment.