commit ec8bb56f7a43087913e992dc33c117b6c8214d90
parent cdd13ca614da11022db8711ab760cad90c863edb
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 20 May 2026 19:34:03 +0200
fix nodeFromUrl() call
Diffstat:
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/Controller/PaivanaController.php b/src/Controller/PaivanaController.php
@@ -65,14 +65,26 @@ class PaivanaController extends ControllerBase {
* load its price category. Returns NULL if no node could be
* resolved.
*/
- protected function nodeFromUrl(string $url): ?NodeInterface {
- $base = $this->getRequest()->getSchemeAndHttpHost();
+ protected function nodeFromUrl(Request $request, string $url): ?NodeInterface {
+ $base = $request->getSchemeAndHttpHost();
if (strpos($url, $base) !== 0) {
// The fulfillment URL must live on this site, otherwise we
// have nothing meaningful to validate against.
return NULL;
}
$path = parse_url($url, PHP_URL_PATH) ?: '/';
+ // Strip the language prefix (e.g. "/en/node/3" -> "/node/3") so
+ // the alias manager, which is language-agnostic, can resolve it.
+ foreach ($this->languageManager()->getLanguages() as $language) {
+ $prefix = '/' . $language->getId();
+ if ($path === $prefix || strpos($path, $prefix . '/') === 0) {
+ $path = substr($path, strlen($prefix));
+ if ($path === '') {
+ $path = '/';
+ }
+ break;
+ }
+ }
// Resolve any path alias (e.g. "/articles/foo") down to "/node/123".
$internal = $this->aliasManager->getPathByAlias($path);
if (! preg_match('#^/node/(\d+)$#', $internal, $m)) {
@@ -166,7 +178,7 @@ class PaivanaController extends ControllerBase {
// Resolve the website to a Drupal node so we can determine the
// price category and thus the set of acceptable amounts.
- $node = $this->nodeFromUrl($website);
+ $node = $this->nodeFromUrl($request, $website);
if (! $node) {
\Drupal::logger('taler_turnstile')->warning('Confirm: cannot resolve fulfillment URL @url to a node', ['@url' => $website]);
return new JsonResponse(['error' => 'unknown_fulfillment_url'], 404);