Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

A Tiny Regex Bug in Adyen's Java Library, and How My Fix Shipped in SDK v42.0.0

Описание и применение

Небольшая ошибка регулярного выражения в Java‑SDK Adyen приводила к неверному переключению тестовых и живых URL. Исправление заменило replaceFirst на replace, добавлен тест, PR принят и включён в SDK v42.0.0.

Задача

A regex misuse in Adyen's Java API Library caused test URLs to be incorrectly replaced with live URLs, risking misdirected payment calls.

Результат

The regex bug was fixed by switching to literal string replacement, a new test was added to guard against regressions, and the change was merged and released in SDK v42.0.0.

Рабочий процесс

  • Identify the bug in Service.java’s createBaseURL method.
  • Replace replaceFirst calls with replace for literal dot matching.
  • Add a test testLivePalUrlOnlyMatchesLiteralDots() to verify non-dot URLs are untouched.
  • Run mvn spotless:apply to satisfy formatting checks.
  • Run tests to confirm failure before fix and success after.
  • Submit PR #1952 to Adyen/adyen-java-api-library.
  • Merge and ship the change in SDK v42.0.0.

Доказательства

The method createBaseURL in Service.java swaps test URLs for live URLs. It used String.replaceFirst() to do that.

Источник

replaceFirst() takes a regex, not a plain string. In regex, a dot . means "any character".

Источник

I replaced the affected replaceFirst() calls with String.replace(), which matches plain text with no regex at all.

Источник

I also added a test, testLivePalUrlOnlyMatchesLiteralDots(), using a URL shaped like pal-testXadyenYcom.

Источник

The PR was approved and merged, and the change shipped in SDK v42.0.0.

Источник

  • Дата записи: 2026-11-03T03:43:45.209Z