summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/File.php13
-rw-r--r--classes/Notice.php2
-rw-r--r--lib/rssaction.php2
-rw-r--r--lib/twitterapi.php2
4 files changed, 16 insertions, 3 deletions
diff --git a/classes/File.php b/classes/File.php
index 533cc6e71..56d9f9827 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -193,5 +193,18 @@ class File extends Memcached_DataObject
return 'http://'.$server.$path.$filename;
}
+
+ function isEnclosure(){
+ if(isset($this->filename)){
+ return true;
+ }
+ $notEnclosureMimeTypes = array('text/html','application/xhtml+xml');
+ $mimetype = strtolower($this->mimetype);
+ $semicolon = strpos($mimetype,';');
+ if($semicolon){
+ $mimetype = substr($mimetype,0,$semicolon);
+ }
+ return(! in_array($mimetype,$notEnclosureMimeTypes));
+ }
}
diff --git a/classes/Notice.php b/classes/Notice.php
index fc28f3558..08125cf7b 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -1170,7 +1170,7 @@ class Notice extends Memcached_DataObject
$attachments = $this->attachments();
if($attachments){
foreach($attachments as $attachment){
- if (isset($attachment->filename)) {
+ if ($attachment->isEnclosure()) {
$attributes = array('rel'=>'enclosure','href'=>$attachment->url,'type'=>$attachment->mimetype,'length'=>$attachment->size);
if($attachment->title){
$attributes['title']=$attachment->title;
diff --git a/lib/rssaction.php b/lib/rssaction.php
index 183c09f47..ffa1f9e99 100644
--- a/lib/rssaction.php
+++ b/lib/rssaction.php
@@ -237,7 +237,7 @@ class Rss10Action extends Action
$attachments = $notice->attachments();
if($attachments){
foreach($attachments as $attachment){
- if (isset($attachment->filename)) {
+ if ($attachment->isEnclosure()) {
// DO NOT move xmlns declaration to root element. Making it
// the default namespace here improves compatibility with
// real-world feed readers.
diff --git a/lib/twitterapi.php b/lib/twitterapi.php
index ce188e00d..655b6c777 100644
--- a/lib/twitterapi.php
+++ b/lib/twitterapi.php
@@ -218,7 +218,7 @@ class TwitterapiAction extends Action
if($attachments){
$entry['enclosures']=array();
foreach($attachments as $attachment){
- if (isset($attachment->filename)) {
+ if ($attachment->isEnclosure()) {
$enclosure=array();
$enclosure['url']=$attachment->url;
$enclosure['mimetype']=$attachment->mimetype;