Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions alpha/apps/kaltura/lib/kMrssManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,23 @@ public static function getEntryMrss(entry $entry, SimpleXMLElement $mrss = null,
$mrss = self::getEntryMrssXml($entry, $mrss, $mrssParams);
return $mrss->asXML();
}


protected static function enforceHttpsIfRequired($partnerId, $url)
{
try
{
$partner = PartnerPeer::retrieveByPK($partnerId);
if ($partner && $partner->getEnforceHttpsApi())
{
$url = str_replace('http://', 'https://', $url);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case the URL contains http:// more than once, better limit it to the first occurance
if (strpos($url, 'http://') === 0)
{
$url = 'https://' . substr($url, 7);
}

}
} catch (Exception $e)
{
KalturaLog::err('Failed to enforce HTTPS for URL: ' . $e->getMessage());
}
return $url;
}

/**
* @param thumbAsset $thumbAsset
* @param SimpleXMLElement $mrss
Expand All @@ -262,11 +278,13 @@ protected static function appendThumbAssetMrss(thumbAsset $thumbAsset, SimpleXML
{
$cdnUrl = $cdnUrlPartners[$thumbAsset->getPartnerId()];
$assetUrl = kAssetUtils::getAssetUrl($thumbAsset, false, null, null, '', $cdnUrl);
$assetUrl = self::enforceHttpsIfRequired($thumbAsset->getPartnerId(),$assetUrl);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space after come

$thumbnail->addAttribute('url', $assetUrl);
}
else
{
$assetUrl = kAssetUtils::getAssetUrl($thumbAsset);
$assetUrl = self::enforceHttpsIfRequired($thumbAsset->getPartnerId(),$assetUrl);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space after come

$thumbnail->addAttribute('url', !is_null($assetUrl) ? $assetUrl : '');
}
$thumbnail->addAttribute('thumbAssetId', $thumbAsset->getId());
Expand Down Expand Up @@ -477,7 +495,9 @@ public static function getEntryMrssXml(entry $entry, SimpleXMLElement $mrss = nu
$mrss->addChild('status', self::stringToSafeXml($entry->getStatus()));
$mrss->addChild('description', self::stringToSafeXml($entry->getDescription()));
$thumbnailUrl = $mrss->addChild('thumbnailUrl');
$thumbnailUrl->addAttribute('url', $entry->getThumbnailUrl($entry->getThumbnailVersion()));
$url = $entry->getThumbnailUrl($entry->getThumbnailVersion());
$url = self::enforceHttpsIfRequired($entry->getPartnerId(), $url);
$thumbnailUrl->addAttribute('url', $url);
if(trim($entry->getTags(), " \r\n\t"))
{
$tags = $mrss->addChild('tags');
Expand Down