diff --git a/.temp/iframe-inner.html b/.temp/iframe-inner.html new file mode 100644 index 0000000..02494c7 --- /dev/null +++ b/.temp/iframe-inner.html @@ -0,0 +1,22 @@ +
+ + + + + + \ No newline at end of file diff --git a/src/Embed/Embed.php b/src/Embed/Embed.php index 80ab284..c8e6023 100644 --- a/src/Embed/Embed.php +++ b/src/Embed/Embed.php @@ -2,6 +2,7 @@ namespace Hyvor\Unfold\Embed; +use Hyvor\Unfold\Embed\Iframe\PrivacyIframe; use Hyvor\Unfold\Exception\EmbedUnableToResolveException; use Hyvor\Unfold\Exception\EmbedParserException; use Hyvor\Unfold\Exception\UnfoldException; @@ -19,11 +20,11 @@ public static function getParsers(): array $namespace = __NAMESPACE__ . '\\Platforms\\'; $parsers = array_map( - fn ($file) => $namespace . pathinfo((string)$file, PATHINFO_FILENAME), + fn($file) => $namespace . pathinfo((string)$file, PATHINFO_FILENAME), (array)glob(__DIR__ . '/Platforms/*.php') ); - usort($parsers, fn ($a, $b) => $b::PRIORITY <=> $a::PRIORITY); + usort($parsers, fn($a, $b) => $b::PRIORITY <=> $a::PRIORITY); return $parsers; } @@ -73,6 +74,10 @@ public static function getUnfoldedObject( ): Unfolded { $oembed = self::parse($url, $context->config); + if ($context->config->embedIframeEndpoint && $oembed->html) { + $oembed->html = PrivacyIframe::wrap($oembed->html); + } + return Unfolded::fromEmbed( $oembed, $url, diff --git a/src/Embed/Iframe/PrivacyIframe.php b/src/Embed/Iframe/PrivacyIframe.php index 907c834..b5876c2 100644 --- a/src/Embed/Iframe/PrivacyIframe.php +++ b/src/Embed/Iframe/PrivacyIframe.php @@ -5,4 +5,25 @@ class PrivacyIframe { + public static function wrap(string $html): string + { + $encoded = base64_encode($html); + + return <<