Repository navigation
Conversation
clean() checked $path[0] and $path[1] without checking the length, so
clean(' ') and clean('\\') with a backslash separator raised
"Uninitialized string offset" warnings, as did resolve(''). On Windows
resolve() let ".." remove the drive, so resolve('C:\..\Windows')
returned the relative path 'Windows' instead of throwing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
The CI failures are unrelated to this change and occur on
|
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 of Changes
Path::clean()checked$path[0]and$path[1]aftertrim()without a length check, so with$ds = '\\'bothclean(' ')andclean('\\')raisedUninitialized string offsetwarnings. It now usesstr_starts_with().Path::resolve('')read$path[0]and raised the same warning. It now returns''.resolve()let..remove the drive:resolve('C:\..\Windows')returned the relative pathWindowsinstead of throwing. A leading drive (C:) is now treated like the root, so climbing above it throws "Path is outside of the defined root" as it does for/..on Unix. Paths below the drive resolve as before (C:/var/www/foo/../joomla→C:\var\www\joomla). The drive handling is limited to Windows, so the behaviour on other systems is unchanged.Testing Instructions
PathTest::testShortPathsDoNotRaiseWarningscollects warnings fromclean(' ', '\\'),clean('\\', '\\')andresolve(''): three warnings before, none after. NewgetCleanData/getResolveDatarows cover the same inputs.PathTest::testResolveKeepsWindowsDrive(Windows only):resolve('C:\a\..\b')isC:\b,resolve('C:\..\Windows')throws. Before, the latter returnedWindows.Documentation Changes Required
docs/overview.mdgets a "Cleaning and resolving paths" section.#88 rewrites
docs/overview.md; whichever of the two is merged second has to resolve the conflict there. #88's "Paths" section ("resolve()throws aFilesystemExceptionwhen the path climbs above its own root") stays correct and could mention the Windows drive.🤖 Generated with Claude Code