Skip to content

Unescaped dots in replaceFirst regex patterns in Service.createBaseURL #1838

Description

@gcatanese

Problem

In Service.java, the createBaseURL method uses String.replaceFirst() with domain strings that contain unescaped dots (e.g. https://device-api-test.adyen.com).
Since replaceFirst takes a regular expression, each . matches any character rather than a literal dot. This means a URL like https://device-api-testXadyenYcom would be incorrectly matched and transformed.

Affected blocks

The following replaceFirst calls all have this issue:

  • pal- block: https://pal-test.adyen.com/pal/servlet/
  • paltokenization- block: https://paltokenization-test.adyen.com/paltokenization/servlet/
  • checkout- block: https://checkout-test.adyen.com/
  • device-api- block: https://device-api-test.adyen.com

Fix

Escape the dots in each regex pattern, e.g.:

url = url.replaceFirst("https://device-api-test\\.adyen\\.com", "https://device-api-live.adyen.com");

Or use String.replace() instead of replaceFirst() where no regex features are needed, since these are all plain prefix substitutions on well-known URL strings.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions