diff --git a/CHANGELOG.md b/CHANGELOG.md index 38f96b0a9..a65e3a13a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ 3. [](#bugfix) * Fixed locking and reading files using `Framework\File` classes * Fixed `Utils::resolveTokenPath()` with `@variable@` not working properly + * Fixed remote URLs in markdown if using subfolder setup # v1.7.33 ## mm/dd/2022 diff --git a/system/src/Grav/Common/Page/Markdown/Excerpts.php b/system/src/Grav/Common/Page/Markdown/Excerpts.php index 17f9cbff5..8d7ad16c9 100644 --- a/system/src/Grav/Common/Page/Markdown/Excerpts.php +++ b/system/src/Grav/Common/Page/Markdown/Excerpts.php @@ -97,6 +97,10 @@ class Excerpts { $grav = Grav::instance(); $url = htmlspecialchars_decode(rawurldecode($excerpt['element']['attributes']['href'])); + if (Uri::isExternal($url) && !str_starts_with($url, $grav['base_url_absolute'])) { + return $excerpt; + } + $url_parts = $this->parseUrl($url); // If there is a query, then parse it and build action calls. @@ -185,7 +189,12 @@ class Excerpts */ public function processImageExcerpt(array $excerpt): array { + $grav = Grav::instance(); $url = htmlspecialchars_decode(urldecode($excerpt['element']['attributes']['src'])); + if (Uri::isExternal($url) && !str_starts_with($url, $grav['base_url_absolute'])) { + return $excerpt; + } + $url_parts = $this->parseUrl($url); $media = null; @@ -196,7 +205,6 @@ class Excerpts $media = $this->page->getMedia(); } else { - $grav = Grav::instance(); /** @var Pages $pages */ $pages = $grav['pages'];