fix: prevent malformed API paths (double slashes, undefined segments, full URLs)#916
Closed
kptdobe wants to merge 1 commit into
Closed
fix: prevent malformed API paths (double slashes, undefined segments, full URLs)#916kptdobe wants to merge 1 commit into
kptdobe wants to merge 1 commit into
Conversation
… full URLs) - Reconstruct details.fullpath from sanitized pathParts (not raw hash) to strip double slashes - Guard fetchDaConfigs against empty org to avoid /config//undefined/ requests - Reject saveToDa calls where path is falsy, non-relative, or a full URL Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
Commits
|
Contributor
Author
|
Reopening from correctly named branch |
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
This PR fixes three distinct patterns of malformed API paths that caused 400 bad requests against da-admin.
Fix 1 — Double slashes in API paths (
/list/org/repo//path, etc.)File:
blocks/shared/pathDetails.jsRoot cause:
details.fullpathwas set from the raw hash string, which preserved any//in the user's URL.sanitizePathPartsstrips double slashes for internal parsing butdetails.fullpathused the raw string, flowing into every API call.Fix: Snapshot
pathPartsafter theisFolderdetection (beforegetFullDetailsmutates the array via.pop()), then reconstruct the canonical path from those sanitized parts instead of the raw hash.Fix 2 —
/config//undefined/requestsFile:
blocks/shared/utils.js—fetchDaConfigsRoot cause: No guard on
orgbeing falsy. Iforgis an empty string andsiteis a truthy"undefined"string,fetchConfig(\/${org}/${site}`)producedfetchConfig("//undefined")→ URL/config//undefined/`.Fix: Return
[Promise.resolve(null)]early whenorgis falsy, before any cache or fetch logic runs.Fix 3 —
/source/https://da.liverequestsFile:
blocks/shared/utils.js—saveToDaRoot cause:
saveToDaconstructed${DA_ORIGIN}/source${path}butpathcould arrive as a full URL from a caller that skipped relative-path extraction, producing a doubly-concatenated URL.Fix: Validate
pathat entry — returnundefinedearly whenpathis falsy, does not start with/, or contains://.Test plan
getPathDetailswith a hash containing//returns afullpathwith no double slashesfetchDaConfigs({ org: '', site: 'something' })returns early with[null]and makes no fetch callssaveToDa({ path: 'https://da.live' })returnsundefinedwithout callingdaFetch🤖 Generated with Claude Code