mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-19 21:43:42 +00:00
[twitter] Don't skip URL entity replacement if OEmbed result is unexpected
This commit is contained in:
parent
5bd67d0d46
commit
f0eb29cb90
1 changed files with 6 additions and 9 deletions
|
@ -1388,7 +1388,6 @@ function twitter_expand_entities($body, stdClass $status, $picture)
|
||||||
$plain = str_replace($url->url, '', $plain);
|
$plain = str_replace($url->url, '', $plain);
|
||||||
|
|
||||||
if ($url->url && $url->expanded_url && $url->display_url) {
|
if ($url->url && $url->expanded_url && $url->display_url) {
|
||||||
|
|
||||||
// Quote tweet, we just remove the quoted tweet URL from the body, the share block will be added later.
|
// Quote tweet, we just remove the quoted tweet URL from the body, the share block will be added later.
|
||||||
if (!empty($status->quoted_status) && isset($status->quoted_status_id_str)
|
if (!empty($status->quoted_status) && isset($status->quoted_status_id_str)
|
||||||
&& substr($url->expanded_url, -strlen($status->quoted_status_id_str)) == $status->quoted_status_id_str
|
&& substr($url->expanded_url, -strlen($status->quoted_status_id_str)) == $status->quoted_status_id_str
|
||||||
|
@ -1406,23 +1405,19 @@ function twitter_expand_entities($body, stdClass $status, $picture)
|
||||||
|
|
||||||
$oembed_data = OEmbed::fetchURL($final_url);
|
$oembed_data = OEmbed::fetchURL($final_url);
|
||||||
|
|
||||||
if (empty($oembed_data) || empty($oembed_data->type)) {
|
$type = $oembed_data->type ?? '';
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Quickfix: Workaround for URL with '[' and ']' in it
|
// Quickfix: Workaround for URL with '[' and ']' in it
|
||||||
if (strpos($expanded_url, '[') || strpos($expanded_url, ']')) {
|
if (strpos($expanded_url, '[') || strpos($expanded_url, ']')) {
|
||||||
$expanded_url = $url->url;
|
$expanded_url = $url->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oembed_data->type == 'video') {
|
if ($type === 'video') {
|
||||||
$attachmentUrl = $expanded_url;
|
$attachmentUrl = $expanded_url;
|
||||||
$replace = '';
|
$replace = '';
|
||||||
} elseif (($oembed_data->type == 'photo') && isset($oembed_data->url)) {
|
} elseif ($type === 'photo' && !empty($oembed_data->url)) {
|
||||||
$replace = '[url=' . $expanded_url . '][img]' . $oembed_data->url . '[/img][/url]';
|
$replace = '[url=' . $expanded_url . '][img]' . $oembed_data->url . '[/img][/url]';
|
||||||
} elseif ($oembed_data->type != 'link') {
|
} elseif ($type === 'link') {
|
||||||
$replace = '[url=' . $expanded_url . ']' . $url->display_url . '[/url]';
|
|
||||||
} else {
|
|
||||||
$img_str = DI::httpRequest()->fetch($final_url, 4);
|
$img_str = DI::httpRequest()->fetch($final_url, 4);
|
||||||
|
|
||||||
$tempfile = tempnam(get_temppath(), 'cache');
|
$tempfile = tempnam(get_temppath(), 'cache');
|
||||||
|
@ -1443,6 +1438,8 @@ function twitter_expand_entities($body, stdClass $status, $picture)
|
||||||
$attachmentUrl = $expanded_url;
|
$attachmentUrl = $expanded_url;
|
||||||
$replace = '';
|
$replace = '';
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$replace = '[url=' . $expanded_url . ']' . $url->display_url . '[/url]';
|
||||||
}
|
}
|
||||||
|
|
||||||
$replacementList[$url->indices[0]] = [
|
$replacementList[$url->indices[0]] = [
|
||||||
|
|
Loading…
Reference in a new issue