Version 5.0.14
This commit is contained in:
1 parent
5efe744c5f
commit
dbd774b30c
364 files changed
+7048
-1377
No files matched your search
+86
-1
@@ -61,12 +61,17 @@ use function array_key_exists;
|
||||
use function chr;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function explode;
|
||||
use function function_exists;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function intval;
|
||||
use function is_array;
|
||||
use function is_string;
|
||||
use function json_decode;
|
||||
use function md5;
|
||||
use function mt_rand;
|
||||
use function preg_quote;
|
||||
use function str_replace;
|
||||
use function substr;
|
||||
use const IPS\DEFAULT_REQUEST_TIMEOUT;
|
||||
@@ -1040,6 +1045,11 @@ class Parser
|
||||
$return[] = 'ipsEmbeddedVideo';
|
||||
$return[] = 'ipsEmbeddedVideo_limited';
|
||||
$return[] = 'ipsEmbeddedOther';
|
||||
$return[] = 'ipsEmbeddedOther--google-maps';
|
||||
$return[] = 'ipsEmbeddedOther--iframely';
|
||||
$return[] = 'iframely-embed';
|
||||
$return[] = 'iframely-player';
|
||||
$return[] = 'iframely-responsive';
|
||||
$return[] = 'ipsEmbeddedOther_limited';
|
||||
$return[] = 'ipsRawIframe';
|
||||
$return[] = 'ipsEmbedded__wrap';
|
||||
@@ -2461,6 +2471,57 @@ class Parser
|
||||
'bsky.app' => [ 'https://embed.bsky.app/oembed', static::EMBED_TWEET ]
|
||||
);
|
||||
|
||||
|
||||
/* Can we support iframely? */
|
||||
if ( Settings::i()->iframely_enabled and Settings::i()->iframely_api_key and ( Settings::i()->iframely_url_whitelist or Settings::i()->iframely_facebook_enabled or Settings::i()->iframely_instagram_enabled ) )
|
||||
{
|
||||
$patterns = [];
|
||||
|
||||
$builtins = [];
|
||||
if ( Settings::i()->iframely_facebook_enabled )
|
||||
{
|
||||
$builtins[] = "facebook\\.com";
|
||||
$builtins[] = "fb\\.watch";
|
||||
}
|
||||
|
||||
if ( Settings::i()->iframely_instagram_enabled )
|
||||
{
|
||||
$builtins[] = "instagram\\.com";
|
||||
$builtins[] = "instagr\\.am";
|
||||
}
|
||||
|
||||
if ( !empty( $builtins ) )
|
||||
{
|
||||
$patterns[] = "((?:www\\.)?(?:" . implode( "|", $builtins ) . "))";
|
||||
}
|
||||
|
||||
if ( Settings::i()->iframely_url_whitelist )
|
||||
{
|
||||
$sym1 = md5( mt_rand() );
|
||||
$sym2 = md5( mt_rand() );
|
||||
foreach ( explode( ',', Settings::i()->iframely_url_whitelist ) as $domainPattern )
|
||||
{
|
||||
if ( mb_strpos( $domainPattern, '*' ) !== false )
|
||||
{
|
||||
$patterns[] = "(" . str_replace( [ $sym1, $sym2 ], [ '\.', '.*?' ], preg_quote( str_replace( array( '.', '*' ), array( $sym1, $sym2 ), $domainPattern ) ) ) . ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$patterns[] = "(" . preg_quote( $domainPattern ) . ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !empty( $patterns ) )
|
||||
{
|
||||
$services["/^" . implode( "|", $patterns ) . "$/i"] = [
|
||||
(string) Url::external( "https://iframe.ly/api/oembed" )->setQueryString([ 'key' => Settings::i()->iframely_api_key, 'omit_script' => 1, 'card' => 0, 'omit_css' => 0 ]),
|
||||
static::EMBED_STATUS
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Can we support Facebook and Instagram oembeds? */
|
||||
if( $token = static::getFacebookToken() )
|
||||
{
|
||||
@@ -2632,7 +2693,25 @@ class Parser
|
||||
{
|
||||
foreach( $oembedServices as $k => $v )
|
||||
{
|
||||
if( mb_strpos( $k, '*' ) !== FALSE )
|
||||
// The pattern might be a regex expression (see iframely)
|
||||
if ( preg_match( '/^\\/(.*[^\\\\])?\\/[iuxasmdg]*?$/i', $k ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
// Since this is used for iframely, where domain patterns are intended to be exact, we use the raw domain without the wwww. subhost removed
|
||||
if ( preg_match( $k, $url->data['host'] ) )
|
||||
{
|
||||
$entry = $v;
|
||||
$entryKey = $k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch( Exception )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if( mb_strpos( $k, '*' ) !== FALSE )
|
||||
{
|
||||
if( preg_match( "/^" . str_replace( array( '.', '*' ), array( '\\.', '.*?' ), $k ) . "$/i", $domain ) )
|
||||
{
|
||||
@@ -2779,6 +2858,12 @@ class Parser
|
||||
{
|
||||
$response['type'] = 'rich';
|
||||
}
|
||||
|
||||
/* Iframely rich embeds don't need our wrapper. */
|
||||
if ( str_starts_with( $endpoint, "https://iframe.ly" ) and !in_array( @$response['type'], [ 'video', 'photo' ] ) and isset( $response['html'] ) )
|
||||
{
|
||||
return Theme::i()->getTemplate( 'embed', 'core', 'global' )->iframely( $response['html'] );
|
||||
}
|
||||
|
||||
/* We need a type otherwise we can't embed */
|
||||
if( !isset( $response['type'] ) )
|
||||
|
||||
Reference in new issue
Block a user