From 952e7953802a388ad9f0d0722faeae61a5c050ac Mon Sep 17 00:00:00 2001 From: Felipe Date: Wed, 22 Jul 2026 15:20:16 +0200 Subject: [PATCH] fix(graphql): escape host in resolve-uris preg_match pattern get_site_url()/get_next_url() hosts are interpolated straight into the preg_match pattern that gates URL rewriting. On sub-path installs the host contains a slash (e.g. "localhost/us"), which is read as the regex delimiter, so PHP parses the remainder as modifiers and emits "preg_match(): Unknown modifier '|'" on every resolved URI field. Wrap both hosts in preg_quote(..., '/') so slashes and other regex-special characters are treated literally. --- wordpress/theme/includes/graphql/resolve-uris.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wordpress/theme/includes/graphql/resolve-uris.php b/wordpress/theme/includes/graphql/resolve-uris.php index 8b78808..7e9b105 100644 --- a/wordpress/theme/includes/graphql/resolve-uris.php +++ b/wordpress/theme/includes/graphql/resolve-uris.php @@ -61,6 +61,11 @@ public function graphql_resolve_relative_uris($result, $source, $args, $context, $site_url = preg_replace('/https?:\/\//', '', get_site_url()); $next_url = preg_replace('/https?:\/\//', '', get_next_url()); + // Escape the hosts: they can contain slashes (e.g. sub-path installs like + // "localhost/subsite"), which would otherwise be read as the regex delimiter. + $site_url = preg_quote($site_url, '/'); + $next_url = preg_quote($next_url, '/'); + // Do not continue if the result is not a BE nor a FE url if (! preg_match("/^https?:\/\/($site_url|$next_url)/i", $result)) return $result;