Skip to content

Encode dynamic API path values as segments - #431

Open
0xmrma wants to merge 1 commit into
apple:mainfrom
0xmrma:encode-api-path-segments
Open

Encode dynamic API path values as segments#431
0xmrma wants to merge 1 commit into
apple:mainfrom
0xmrma:encode-api-path-segments

Conversation

@0xmrma

@0xmrma 0xmrma commented Aug 27, 2026

Copy link
Copy Markdown

Summary

Encode all caller-provided values that are inserted into App Store Server API URL paths. This preserves each value as one path segment and prevents URL parsing from treating slashes, query delimiters, fragments, or dot segments as request-target syntax.

What changed

  • Added a single encodePathSegment helper to AppStoreServerAPIClient.
  • Applied it to every dynamic path component used by the client, including transaction identifiers, order identifiers, notification tokens, messaging identifiers, product IDs, locales, performance-test identifiers, and the transaction-history version.
  • Added special handling for exact . and .. values because WHATWG URL parsing normalizes even their percent-encoded forms. These values are encoded again so they cannot remove or traverse URL path segments.
  • Added regression coverage for slash-containing values, query and fragment delimiters, exact dot segments, and ordinary identifiers.

Behavioral effect

For normal identifiers such as com.example.product and en-US, the generated paths are unchanged. Values containing URL syntax characters are serialized as data inside one path segment, allowing the server to reject malformed identifiers without the client changing the structure of the request path.

This also keeps the public method boundary aligned with the request target: a value containing URL syntax characters remains data inside the parameter’s path segment instead of changing the structure of the request path.

Validation

  • npm run build
  • npm test -- --runInBand

Result: 20 test suites passed, 332 tests passed.

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.

1 participant