<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[19890] trunk/wp-includes/class-simplepie.php: Upgrade SimplePie to 1.2.1.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/19890">19890</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2012-02-09 20:15:22 +0000 (Thu, 09 Feb 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Upgrade SimplePie to 1.2.1. Props nacin. fixes <a href="http://core.trac.wordpress.org/ticket/18309">#18309</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesclasssimplepiephp">trunk/wp-includes/class-simplepie.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesclasssimplepiephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-simplepie.php (19889 => 19890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-simplepie.php        2012-02-09 19:53:53 UTC (rev 19889)
+++ trunk/wp-includes/class-simplepie.php        2012-02-09 20:15:22 UTC (rev 19890)
</span><span class="lines">@@ -1,12 +1,12 @@
</span><span class="cx"> &lt;?php
</span><del>-if ( !class_exists( 'SimplePie' ) ) :
</del><ins>+if ( ! class_exists( 'SimplePie' ) ) :
</ins><span class="cx"> /**
</span><span class="cx">  * SimplePie
</span><span class="cx">  *
</span><span class="cx">  * A PHP-Based RSS and Atom Feed Framework.
</span><span class="cx">  * Takes the hard work out of managing a complete RSS/Atom solution.
</span><span class="cx">  *
</span><del>- * Copyright (c) 2004-2009, Ryan Parman and Geoffrey Sneddon
</del><ins>+ * Copyright (c) 2004-2011, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
</ins><span class="cx">  * All rights reserved.
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without modification, are
</span><span class="lines">@@ -34,10 +34,11 @@
</span><span class="cx">  * POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  *
</span><span class="cx">  * @package SimplePie
</span><del>- * @version 1.2
- * @copyright 2004-2009 Ryan Parman, Geoffrey Sneddon
</del><ins>+ * @version 1.2.1
+ * @copyright 2004-2011 Ryan Parman, Geoffrey Sneddon, Ryan McCue
</ins><span class="cx">  * @author Ryan Parman
</span><span class="cx">  * @author Geoffrey Sneddon
</span><ins>+ * @author Ryan McCue
</ins><span class="cx">  * @link http://simplepie.org/ SimplePie
</span><span class="cx">  * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
</span><span class="cx">  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
</span><span class="lines">@@ -52,12 +53,12 @@
</span><span class="cx"> /**
</span><span class="cx">  * SimplePie Version
</span><span class="cx">  */
</span><del>-define('SIMPLEPIE_VERSION', '1.2');
</del><ins>+define('SIMPLEPIE_VERSION', '1.2.1');
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * SimplePie Build
</span><span class="cx">  */
</span><del>-define('SIMPLEPIE_BUILD', '20090627192103');
</del><ins>+define('SIMPLEPIE_BUILD', '20111015034325');
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * SimplePie Website URL
</span><span class="lines">@@ -1672,7 +1673,7 @@
</span><span class="cx">                                                                 $this-&gt;data = array('url' =&gt; $this-&gt;feed_url, 'feed_url' =&gt; $file-&gt;url, 'build' =&gt; SIMPLEPIE_BUILD);
</span><span class="cx">                                                                 if (!$cache-&gt;save($this))
</span><span class="cx">                                                                 {
</span><del>-                                                                        trigger_error(&quot;$this-&gt;cache_location is not writeable&quot;, E_USER_WARNING);
</del><ins>+                                                                        trigger_error(&quot;$this-&gt;cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.&quot;, E_USER_WARNING);
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                                 $cache = call_user_func(array($this-&gt;cache_class, 'create'), $this-&gt;cache_location, call_user_func($this-&gt;cache_name_function, $file-&gt;url), 'spc');
</span><span class="cx">                                                         }
</span><span class="lines">@@ -1680,7 +1681,7 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                                 else
</span><span class="cx">                                                 {
</span><del>-                                                        $this-&gt;error = &quot;A feed could not be found at $this-&gt;feed_url&quot;;
</del><ins>+                                                        $this-&gt;error = &quot;A feed could not be found at $this-&gt;feed_url. A feed with an invalid mime type may fall victim to this error, or &quot; . SIMPLEPIE_NAME . &quot; was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed.&quot;;
</ins><span class="cx">                                                         SimplePie_Misc::error($this-&gt;error, E_USER_NOTICE, __FILE__, __LINE__);
</span><span class="cx">                                                         return false;
</span><span class="cx">                                                 }
</span><span class="lines">@@ -1777,27 +1778,27 @@
</span><span class="cx">                                                         // Cache the file if caching is enabled
</span><span class="cx">                                                         if ($cache &amp;&amp; !$cache-&gt;save($this))
</span><span class="cx">                                                         {
</span><del>-                                                                trigger_error(&quot;$cache-&gt;name is not writeable&quot;, E_USER_WARNING);
</del><ins>+                                                                trigger_error(&quot;$this-&gt;cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.&quot;, E_USER_WARNING);
</ins><span class="cx">                                                         }
</span><span class="cx">                                                         return true;
</span><span class="cx">                                                 }
</span><span class="cx">                                                 else
</span><span class="cx">                                                 {
</span><del>-                                                        $this-&gt;error = &quot;A feed could not be found at $this-&gt;feed_url&quot;;
</del><ins>+                                                        $this-&gt;error = &quot;A feed could not be found at $this-&gt;feed_url. This does not appear to be a valid RSS or Atom feed.&quot;;
</ins><span class="cx">                                                         SimplePie_Misc::error($this-&gt;error, E_USER_NOTICE, __FILE__, __LINE__);
</span><span class="cx">                                                         return false;
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        if(isset($parser))
</del><ins>+                        if (isset($parser))
</ins><span class="cx">                         {
</span><span class="cx">                                 // We have an error, just set SimplePie_Misc::error to it and quit
</span><del>-                                $this-&gt;error = sprintf('XML error: %s at line %d, column %d', $parser-&gt;get_error_string(), $parser-&gt;get_current_line(), $parser-&gt;get_current_column());
</del><ins>+                                $this-&gt;error = sprintf('This XML document is invalid, likely due to invalid characters. XML error: %s at line %d, column %d', $parser-&gt;get_error_string(), $parser-&gt;get_current_line(), $parser-&gt;get_current_column());
</ins><span class="cx">                         }
</span><span class="cx">                         else
</span><span class="cx">                         {
</span><del>-                                $this-&gt;error = 'The data could not be converted to UTF-8';
</del><ins>+                                $this-&gt;error = 'The data could not be converted to UTF-8. You MUST have either the iconv or mbstring extension installed. Upgrading to PHP 5.x (which includes iconv) is highly recommended.';
</ins><span class="cx">                         }
</span><span class="cx">                         SimplePie_Misc::error($this-&gt;error, E_USER_NOTICE, __FILE__, __LINE__);
</span><span class="cx">                         return false;
</span><span class="lines">@@ -1831,7 +1832,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Return the error message for the occurred error
</del><ins>+         * Return the error message for the occured error
</ins><span class="cx">          *
</span><span class="cx">          * @access public
</span><span class="cx">          * @return string Error message
</span><span class="lines">@@ -1984,7 +1985,7 @@
</span><span class="cx">                                                         }
</span><span class="cx">                                                         else
</span><span class="cx">                                                         {
</span><del>-                                                                trigger_error(&quot;$cache-&gt;name is not writeable&quot;, E_USER_WARNING);
</del><ins>+                                                                trigger_error(&quot;$cache-&gt;name is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.&quot;, E_USER_WARNING);
</ins><span class="cx">                                                                 return $this-&gt;sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
</span><span class="cx">                                                         }
</span><span class="cx">                                                 }
</span><span class="lines">@@ -2774,11 +2775,12 @@
</span><span class="cx"> 
</span><span class="cx">         function get_latitude()
</span><span class="cx">         {
</span><ins>+                
</ins><span class="cx">                 if ($return = $this-&gt;get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
</span><span class="cx">                 {
</span><span class="cx">                         return (float) $return[0]['data'];
</span><span class="cx">                 }
</span><del>-                elseif (($return = $this-&gt;get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) &amp;&amp; preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
</del><ins>+                elseif (($return = $this-&gt;get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) &amp;&amp; preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
</ins><span class="cx">                 {
</span><span class="cx">                         return (float) $match[1];
</span><span class="cx">                 }
</span><span class="lines">@@ -2798,7 +2800,7 @@
</span><span class="cx">                 {
</span><span class="cx">                         return (float) $return[0]['data'];
</span><span class="cx">                 }
</span><del>-                elseif (($return = $this-&gt;get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) &amp;&amp; preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
</del><ins>+                elseif (($return = $this-&gt;get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) &amp;&amp; preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
</ins><span class="cx">                 {
</span><span class="cx">                         return (float) $match[2];
</span><span class="cx">                 }
</span><span class="lines">@@ -3278,6 +3280,11 @@
</span><span class="cx">                 {
</span><span class="cx">                         return $this-&gt;sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</span><span class="cx">                 }
</span><ins>+                elseif ($return = $this-&gt;get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
+                {
+                        return $this-&gt;sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
+                }
+
</ins><span class="cx">                 elseif (!$description_only)
</span><span class="cx">                 {
</span><span class="cx">                         return $this-&gt;get_content(true);
</span><span class="lines">@@ -3642,7 +3649,7 @@
</span><span class="cx">                 {
</span><span class="cx">                         return $this-&gt;sanitize($this-&gt;get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
</span><span class="cx">                 }
</span><del>-                elseif (($date = $this-&gt;get_date('U')) !== null)
</del><ins>+                elseif (($date = $this-&gt;get_date('U')) !== null &amp;&amp; $date !== false)
</ins><span class="cx">                 {
</span><span class="cx">                         return strftime($date_format, $date);
</span><span class="cx">                 }
</span><span class="lines">@@ -4428,621 +4435,624 @@
</span><span class="cx">                         // If we have media:group tags, loop through them.
</span><span class="cx">                         foreach ((array) $this-&gt;get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
</span><span class="cx">                         {
</span><del>-                                // If we have media:content tags, loop through them.
-                                foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
</del><ins>+                                if(isset($group['child']) &amp;&amp; isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
</ins><span class="cx">                                 {
</span><del>-                                        if (isset($content['attribs']['']['url']))
</del><ins>+                                        // If we have media:content tags, loop through them.
+                                        foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
</ins><span class="cx">                                         {
</span><del>-                                                // Attributes
-                                                $bitrate = null;
-                                                $channels = null;
-                                                $duration = null;
-                                                $expression = null;
-                                                $framerate = null;
-                                                $height = null;
-                                                $javascript = null;
-                                                $lang = null;
-                                                $length = null;
-                                                $medium = null;
-                                                $samplingrate = null;
-                                                $type = null;
-                                                $url = null;
-                                                $width = null;
</del><ins>+                                                if (isset($content['attribs']['']['url']))
+                                                {
+                                                        // Attributes
+                                                        $bitrate = null;
+                                                        $channels = null;
+                                                        $duration = null;
+                                                        $expression = null;
+                                                        $framerate = null;
+                                                        $height = null;
+                                                        $javascript = null;
+                                                        $lang = null;
+                                                        $length = null;
+                                                        $medium = null;
+                                                        $samplingrate = null;
+                                                        $type = null;
+                                                        $url = null;
+                                                        $width = null;
</ins><span class="cx"> 
</span><del>-                                                // Elements
-                                                $captions = null;
-                                                $categories = null;
-                                                $copyrights = null;
-                                                $credits = null;
-                                                $description = null;
-                                                $hashes = null;
-                                                $keywords = null;
-                                                $player = null;
-                                                $ratings = null;
-                                                $restrictions = null;
-                                                $thumbnails = null;
-                                                $title = null;
</del><ins>+                                                        // Elements
+                                                        $captions = null;
+                                                        $categories = null;
+                                                        $copyrights = null;
+                                                        $credits = null;
+                                                        $description = null;
+                                                        $hashes = null;
+                                                        $keywords = null;
+                                                        $player = null;
+                                                        $ratings = null;
+                                                        $restrictions = null;
+                                                        $thumbnails = null;
+                                                        $title = null;
</ins><span class="cx"> 
</span><del>-                                                // Start checking the attributes of media:content
-                                                if (isset($content['attribs']['']['bitrate']))
-                                                {
-                                                        $bitrate = $this-&gt;sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                if (isset($content['attribs']['']['channels']))
-                                                {
-                                                        $channels = $this-&gt;sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                if (isset($content['attribs']['']['duration']))
-                                                {
-                                                        $duration = $this-&gt;sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                else
-                                                {
-                                                        $duration = $duration_parent;
-                                                }
-                                                if (isset($content['attribs']['']['expression']))
-                                                {
-                                                        $expression = $this-&gt;sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                if (isset($content['attribs']['']['framerate']))
-                                                {
-                                                        $framerate = $this-&gt;sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                if (isset($content['attribs']['']['height']))
-                                                {
-                                                        $height = $this-&gt;sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                if (isset($content['attribs']['']['lang']))
-                                                {
-                                                        $lang = $this-&gt;sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                if (isset($content['attribs']['']['fileSize']))
-                                                {
-                                                        $length = ceil($content['attribs']['']['fileSize']);
-                                                }
-                                                if (isset($content['attribs']['']['medium']))
-                                                {
-                                                        $medium = $this-&gt;sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                if (isset($content['attribs']['']['samplingrate']))
-                                                {
-                                                        $samplingrate = $this-&gt;sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                if (isset($content['attribs']['']['type']))
-                                                {
-                                                        $type = $this-&gt;sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                if (isset($content['attribs']['']['width']))
-                                                {
-                                                        $width = $this-&gt;sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                $url = $this-&gt;sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
</del><ins>+                                                        // Start checking the attributes of media:content
+                                                        if (isset($content['attribs']['']['bitrate']))
+                                                        {
+                                                                $bitrate = $this-&gt;sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                        }
+                                                        if (isset($content['attribs']['']['channels']))
+                                                        {
+                                                                $channels = $this-&gt;sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                        }
+                                                        if (isset($content['attribs']['']['duration']))
+                                                        {
+                                                                $duration = $this-&gt;sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                        }
+                                                        else
+                                                        {
+                                                                $duration = $duration_parent;
+                                                        }
+                                                        if (isset($content['attribs']['']['expression']))
+                                                        {
+                                                                $expression = $this-&gt;sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                        }
+                                                        if (isset($content['attribs']['']['framerate']))
+                                                        {
+                                                                $framerate = $this-&gt;sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                        }
+                                                        if (isset($content['attribs']['']['height']))
+                                                        {
+                                                                $height = $this-&gt;sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                        }
+                                                        if (isset($content['attribs']['']['lang']))
+                                                        {
+                                                                $lang = $this-&gt;sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                        }
+                                                        if (isset($content['attribs']['']['fileSize']))
+                                                        {
+                                                                $length = ceil($content['attribs']['']['fileSize']);
+                                                        }
+                                                        if (isset($content['attribs']['']['medium']))
+                                                        {
+                                                                $medium = $this-&gt;sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                        }
+                                                        if (isset($content['attribs']['']['samplingrate']))
+                                                        {
+                                                                $samplingrate = $this-&gt;sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                        }
+                                                        if (isset($content['attribs']['']['type']))
+                                                        {
+                                                                $type = $this-&gt;sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                        }
+                                                        if (isset($content['attribs']['']['width']))
+                                                        {
+                                                                $width = $this-&gt;sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                        }
+                                                        $url = $this-&gt;sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
</ins><span class="cx"> 
</span><del>-                                                // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
</del><ins>+                                                        // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
</ins><span class="cx"> 
</span><del>-                                                // CAPTIONS
-                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
-                                                {
-                                                        foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
</del><ins>+                                                        // CAPTIONS
+                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $caption_type = null;
-                                                                $caption_lang = null;
-                                                                $caption_startTime = null;
-                                                                $caption_endTime = null;
-                                                                $caption_text = null;
-                                                                if (isset($caption['attribs']['']['type']))
</del><ins>+                                                                foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $caption_type = $this-&gt;sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $caption_type = null;
+                                                                        $caption_lang = null;
+                                                                        $caption_startTime = null;
+                                                                        $caption_endTime = null;
+                                                                        $caption_text = null;
+                                                                        if (isset($caption['attribs']['']['type']))
+                                                                        {
+                                                                                $caption_type = $this-&gt;sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($caption['attribs']['']['lang']))
+                                                                        {
+                                                                                $caption_lang = $this-&gt;sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($caption['attribs']['']['start']))
+                                                                        {
+                                                                                $caption_startTime = $this-&gt;sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($caption['attribs']['']['end']))
+                                                                        {
+                                                                                $caption_endTime = $this-&gt;sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($caption['data']))
+                                                                        {
+                                                                                $caption_text = $this-&gt;sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        $captions[] =&amp; new $this-&gt;feed-&gt;caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($caption['attribs']['']['lang']))
</del><ins>+                                                                if (is_array($captions))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $caption_lang = $this-&gt;sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $captions = array_values(SimplePie_Misc::array_unique($captions));
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($caption['attribs']['']['start']))
</del><ins>+                                                        }
+                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
+                                                        {
+                                                                foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $caption_startTime = $this-&gt;sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $caption_type = null;
+                                                                        $caption_lang = null;
+                                                                        $caption_startTime = null;
+                                                                        $caption_endTime = null;
+                                                                        $caption_text = null;
+                                                                        if (isset($caption['attribs']['']['type']))
+                                                                        {
+                                                                                $caption_type = $this-&gt;sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($caption['attribs']['']['lang']))
+                                                                        {
+                                                                                $caption_lang = $this-&gt;sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($caption['attribs']['']['start']))
+                                                                        {
+                                                                                $caption_startTime = $this-&gt;sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($caption['attribs']['']['end']))
+                                                                        {
+                                                                                $caption_endTime = $this-&gt;sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($caption['data']))
+                                                                        {
+                                                                                $caption_text = $this-&gt;sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        $captions[] =&amp; new $this-&gt;feed-&gt;caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($caption['attribs']['']['end']))
</del><ins>+                                                                if (is_array($captions))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $caption_endTime = $this-&gt;sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $captions = array_values(SimplePie_Misc::array_unique($captions));
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($caption['data']))
-                                                                {
-                                                                        $caption_text = $this-&gt;sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                                }
-                                                                $captions[] =&amp; new $this-&gt;feed-&gt;caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
</del><span class="cx">                                                         }
</span><del>-                                                        if (is_array($captions))
</del><ins>+                                                        else
</ins><span class="cx">                                                         {
</span><del>-                                                                $captions = array_values(SimplePie_Misc::array_unique($captions));
</del><ins>+                                                                $captions = $captions_parent;
</ins><span class="cx">                                                         }
</span><del>-                                                }
-                                                elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
-                                                {
-                                                        foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
</del><ins>+
+                                                        // CATEGORIES
+                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $caption_type = null;
-                                                                $caption_lang = null;
-                                                                $caption_startTime = null;
-                                                                $caption_endTime = null;
-                                                                $caption_text = null;
-                                                                if (isset($caption['attribs']['']['type']))
</del><ins>+                                                                foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $caption_type = $this-&gt;sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $term = null;
+                                                                        $scheme = null;
+                                                                        $label = null;
+                                                                        if (isset($category['data']))
+                                                                        {
+                                                                                $term = $this-&gt;sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($category['attribs']['']['scheme']))
+                                                                        {
+                                                                                $scheme = $this-&gt;sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        else
+                                                                        {
+                                                                                $scheme = 'http://search.yahoo.com/mrss/category_schema';
+                                                                        }
+                                                                        if (isset($category['attribs']['']['label']))
+                                                                        {
+                                                                                $label = $this-&gt;sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        $categories[] =&amp; new $this-&gt;feed-&gt;category_class($term, $scheme, $label);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($caption['attribs']['']['lang']))
</del><ins>+                                                        }
+                                                        if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
+                                                        {
+                                                                foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $caption_lang = $this-&gt;sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $term = null;
+                                                                        $scheme = null;
+                                                                        $label = null;
+                                                                        if (isset($category['data']))
+                                                                        {
+                                                                                $term = $this-&gt;sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($category['attribs']['']['scheme']))
+                                                                        {
+                                                                                $scheme = $this-&gt;sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        else
+                                                                        {
+                                                                                $scheme = 'http://search.yahoo.com/mrss/category_schema';
+                                                                        }
+                                                                        if (isset($category['attribs']['']['label']))
+                                                                        {
+                                                                                $label = $this-&gt;sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        $categories[] =&amp; new $this-&gt;feed-&gt;category_class($term, $scheme, $label);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($caption['attribs']['']['start']))
-                                                                {
-                                                                        $caption_startTime = $this-&gt;sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                                }
-                                                                if (isset($caption['attribs']['']['end']))
-                                                                {
-                                                                        $caption_endTime = $this-&gt;sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                                }
-                                                                if (isset($caption['data']))
-                                                                {
-                                                                        $caption_text = $this-&gt;sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                                }
-                                                                $captions[] =&amp; new $this-&gt;feed-&gt;caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
</del><span class="cx">                                                         }
</span><del>-                                                        if (is_array($captions))
</del><ins>+                                                        if (is_array($categories) &amp;&amp; is_array($categories_parent))
</ins><span class="cx">                                                         {
</span><del>-                                                                $captions = array_values(SimplePie_Misc::array_unique($captions));
</del><ins>+                                                                $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
</ins><span class="cx">                                                         }
</span><del>-                                                }
-                                                else
-                                                {
-                                                        $captions = $captions_parent;
-                                                }
</del><ins>+                                                        elseif (is_array($categories))
+                                                        {
+                                                                $categories = array_values(SimplePie_Misc::array_unique($categories));
+                                                        }
+                                                        elseif (is_array($categories_parent))
+                                                        {
+                                                                $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
+                                                        }
</ins><span class="cx"> 
</span><del>-                                                // CATEGORIES
-                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
-                                                {
-                                                        foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
</del><ins>+                                                        // COPYRIGHTS
+                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $term = null;
-                                                                $scheme = null;
-                                                                $label = null;
-                                                                if (isset($category['data']))
</del><ins>+                                                                $copyright_url = null;
+                                                                $copyright_label = null;
+                                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $term = $this-&gt;sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $copyright_url = $this-&gt;sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($category['attribs']['']['scheme']))
</del><ins>+                                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $scheme = $this-&gt;sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $copyright_label = $this-&gt;sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</ins><span class="cx">                                                                 }
</span><del>-                                                                else
</del><ins>+                                                                $copyrights =&amp; new $this-&gt;feed-&gt;copyright_class($copyright_url, $copyright_label);
+                                                        }
+                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
+                                                        {
+                                                                $copyright_url = null;
+                                                                $copyright_label = null;
+                                                                if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $scheme = 'http://search.yahoo.com/mrss/category_schema';
</del><ins>+                                                                        $copyright_url = $this-&gt;sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($category['attribs']['']['label']))
</del><ins>+                                                                if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $label = $this-&gt;sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $copyright_label = $this-&gt;sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</ins><span class="cx">                                                                 }
</span><del>-                                                                $categories[] =&amp; new $this-&gt;feed-&gt;category_class($term, $scheme, $label);
</del><ins>+                                                                $copyrights =&amp; new $this-&gt;feed-&gt;copyright_class($copyright_url, $copyright_label);
</ins><span class="cx">                                                         }
</span><del>-                                                }
-                                                if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
-                                                {
-                                                        foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
</del><ins>+                                                        else
</ins><span class="cx">                                                         {
</span><del>-                                                                $term = null;
-                                                                $scheme = null;
-                                                                $label = null;
-                                                                if (isset($category['data']))
</del><ins>+                                                                $copyrights = $copyrights_parent;
+                                                        }
+
+                                                        // CREDITS
+                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
+                                                        {
+                                                                foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $term = $this-&gt;sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $credit_role = null;
+                                                                        $credit_scheme = null;
+                                                                        $credit_name = null;
+                                                                        if (isset($credit['attribs']['']['role']))
+                                                                        {
+                                                                                $credit_role = $this-&gt;sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($credit['attribs']['']['scheme']))
+                                                                        {
+                                                                                $credit_scheme = $this-&gt;sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        else
+                                                                        {
+                                                                                $credit_scheme = 'urn:ebu';
+                                                                        }
+                                                                        if (isset($credit['data']))
+                                                                        {
+                                                                                $credit_name = $this-&gt;sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        $credits[] =&amp; new $this-&gt;feed-&gt;credit_class($credit_role, $credit_scheme, $credit_name);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($category['attribs']['']['scheme']))
</del><ins>+                                                                if (is_array($credits))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $scheme = $this-&gt;sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $credits = array_values(SimplePie_Misc::array_unique($credits));
</ins><span class="cx">                                                                 }
</span><del>-                                                                else
</del><ins>+                                                        }
+                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
+                                                        {
+                                                                foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $scheme = 'http://search.yahoo.com/mrss/category_schema';
</del><ins>+                                                                        $credit_role = null;
+                                                                        $credit_scheme = null;
+                                                                        $credit_name = null;
+                                                                        if (isset($credit['attribs']['']['role']))
+                                                                        {
+                                                                                $credit_role = $this-&gt;sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($credit['attribs']['']['scheme']))
+                                                                        {
+                                                                                $credit_scheme = $this-&gt;sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        else
+                                                                        {
+                                                                                $credit_scheme = 'urn:ebu';
+                                                                        }
+                                                                        if (isset($credit['data']))
+                                                                        {
+                                                                                $credit_name = $this-&gt;sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        $credits[] =&amp; new $this-&gt;feed-&gt;credit_class($credit_role, $credit_scheme, $credit_name);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($category['attribs']['']['label']))
</del><ins>+                                                                if (is_array($credits))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $label = $this-&gt;sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $credits = array_values(SimplePie_Misc::array_unique($credits));
</ins><span class="cx">                                                                 }
</span><del>-                                                                $categories[] =&amp; new $this-&gt;feed-&gt;category_class($term, $scheme, $label);
</del><span class="cx">                                                         }
</span><del>-                                                }
-                                                if (is_array($categories) &amp;&amp; is_array($categories_parent))
-                                                {
-                                                        $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
-                                                }
-                                                elseif (is_array($categories))
-                                                {
-                                                        $categories = array_values(SimplePie_Misc::array_unique($categories));
-                                                }
-                                                elseif (is_array($categories_parent))
-                                                {
-                                                        $categories = array_values(SimplePie_Misc::array_unique($categories_parent));
-                                                }
-
-                                                // COPYRIGHTS
-                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
-                                                {
-                                                        $copyright_url = null;
-                                                        $copyright_label = null;
-                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
</del><ins>+                                                        else
</ins><span class="cx">                                                         {
</span><del>-                                                                $copyright_url = $this-&gt;sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                $credits = $credits_parent;
</ins><span class="cx">                                                         }
</span><del>-                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
</del><ins>+
+                                                        // DESCRIPTION
+                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $copyright_label = $this-&gt;sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                $description = $this-&gt;sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</ins><span class="cx">                                                         }
</span><del>-                                                        $copyrights =&amp; new $this-&gt;feed-&gt;copyright_class($copyright_url, $copyright_label);
-                                                }
-                                                elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
-                                                {
-                                                        $copyright_url = null;
-                                                        $copyright_label = null;
-                                                        if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
</del><ins>+                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $copyright_url = $this-&gt;sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                $description = $this-&gt;sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</ins><span class="cx">                                                         }
</span><del>-                                                        if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
</del><ins>+                                                        else
</ins><span class="cx">                                                         {
</span><del>-                                                                $copyright_label = $this-&gt;sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                $description = $description_parent;
</ins><span class="cx">                                                         }
</span><del>-                                                        $copyrights =&amp; new $this-&gt;feed-&gt;copyright_class($copyright_url, $copyright_label);
-                                                }
-                                                else
-                                                {
-                                                        $copyrights = $copyrights_parent;
-                                                }
</del><span class="cx"> 
</span><del>-                                                // CREDITS
-                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
-                                                {
-                                                        foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
</del><ins>+                                                        // HASHES
+                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $credit_role = null;
-                                                                $credit_scheme = null;
-                                                                $credit_name = null;
-                                                                if (isset($credit['attribs']['']['role']))
</del><ins>+                                                                foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $credit_role = $this-&gt;sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $value = null;
+                                                                        $algo = null;
+                                                                        if (isset($hash['data']))
+                                                                        {
+                                                                                $value = $this-&gt;sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($hash['attribs']['']['algo']))
+                                                                        {
+                                                                                $algo = $this-&gt;sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        else
+                                                                        {
+                                                                                $algo = 'md5';
+                                                                        }
+                                                                        $hashes[] = $algo.':'.$value;
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($credit['attribs']['']['scheme']))
</del><ins>+                                                                if (is_array($hashes))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $credit_scheme = $this-&gt;sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $hashes = array_values(SimplePie_Misc::array_unique($hashes));
</ins><span class="cx">                                                                 }
</span><del>-                                                                else
</del><ins>+                                                        }
+                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
+                                                        {
+                                                                foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $credit_scheme = 'urn:ebu';
</del><ins>+                                                                        $value = null;
+                                                                        $algo = null;
+                                                                        if (isset($hash['data']))
+                                                                        {
+                                                                                $value = $this-&gt;sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($hash['attribs']['']['algo']))
+                                                                        {
+                                                                                $algo = $this-&gt;sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        else
+                                                                        {
+                                                                                $algo = 'md5';
+                                                                        }
+                                                                        $hashes[] = $algo.':'.$value;
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($credit['data']))
</del><ins>+                                                                if (is_array($hashes))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $credit_name = $this-&gt;sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $hashes = array_values(SimplePie_Misc::array_unique($hashes));
</ins><span class="cx">                                                                 }
</span><del>-                                                                $credits[] =&amp; new $this-&gt;feed-&gt;credit_class($credit_role, $credit_scheme, $credit_name);
</del><span class="cx">                                                         }
</span><del>-                                                        if (is_array($credits))
</del><ins>+                                                        else
</ins><span class="cx">                                                         {
</span><del>-                                                                $credits = array_values(SimplePie_Misc::array_unique($credits));
</del><ins>+                                                                $hashes = $hashes_parent;
</ins><span class="cx">                                                         }
</span><del>-                                                }
-                                                elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
-                                                {
-                                                        foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
</del><ins>+
+                                                        // KEYWORDS
+                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $credit_role = null;
-                                                                $credit_scheme = null;
-                                                                $credit_name = null;
-                                                                if (isset($credit['attribs']['']['role']))
</del><ins>+                                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $credit_role = $this-&gt;sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $temp = explode(',', $this-&gt;sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+                                                                        foreach ($temp as $word)
+                                                                        {
+                                                                                $keywords[] = trim($word);
+                                                                        }
+                                                                        unset($temp);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($credit['attribs']['']['scheme']))
</del><ins>+                                                                if (is_array($keywords))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $credit_scheme = $this-&gt;sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $keywords = array_values(SimplePie_Misc::array_unique($keywords));
</ins><span class="cx">                                                                 }
</span><del>-                                                                else
</del><ins>+                                                        }
+                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
+                                                        {
+                                                                if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $credit_scheme = 'urn:ebu';
</del><ins>+                                                                        $temp = explode(',', $this-&gt;sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+                                                                        foreach ($temp as $word)
+                                                                        {
+                                                                                $keywords[] = trim($word);
+                                                                        }
+                                                                        unset($temp);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($credit['data']))
</del><ins>+                                                                if (is_array($keywords))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $credit_name = $this-&gt;sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $keywords = array_values(SimplePie_Misc::array_unique($keywords));
</ins><span class="cx">                                                                 }
</span><del>-                                                                $credits[] =&amp; new $this-&gt;feed-&gt;credit_class($credit_role, $credit_scheme, $credit_name);
</del><span class="cx">                                                         }
</span><del>-                                                        if (is_array($credits))
</del><ins>+                                                        else
</ins><span class="cx">                                                         {
</span><del>-                                                                $credits = array_values(SimplePie_Misc::array_unique($credits));
</del><ins>+                                                                $keywords = $keywords_parent;
</ins><span class="cx">                                                         }
</span><del>-                                                }
-                                                else
-                                                {
-                                                        $credits = $credits_parent;
-                                                }
</del><span class="cx"> 
</span><del>-                                                // DESCRIPTION
-                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
-                                                {
-                                                        $description = $this-&gt;sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
-                                                {
-                                                        $description = $this-&gt;sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                else
-                                                {
-                                                        $description = $description_parent;
-                                                }
-
-                                                // HASHES
-                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
-                                                {
-                                                        foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
</del><ins>+                                                        // PLAYER
+                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $value = null;
-                                                                $algo = null;
-                                                                if (isset($hash['data']))
-                                                                {
-                                                                        $value = $this-&gt;sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                                }
-                                                                if (isset($hash['attribs']['']['algo']))
-                                                                {
-                                                                        $algo = $this-&gt;sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                                }
-                                                                else
-                                                                {
-                                                                        $algo = 'md5';
-                                                                }
-                                                                $hashes[] = $algo.':'.$value;
</del><ins>+                                                                $player = $this-&gt;sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
</ins><span class="cx">                                                         }
</span><del>-                                                        if (is_array($hashes))
</del><ins>+                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $hashes = array_values(SimplePie_Misc::array_unique($hashes));
</del><ins>+                                                                $player = $this-&gt;sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
</ins><span class="cx">                                                         }
</span><del>-                                                }
-                                                elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
-                                                {
-                                                        foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
</del><ins>+                                                        else
</ins><span class="cx">                                                         {
</span><del>-                                                                $value = null;
-                                                                $algo = null;
-                                                                if (isset($hash['data']))
</del><ins>+                                                                $player = $player_parent;
+                                                        }
+
+                                                        // RATINGS
+                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
+                                                        {
+                                                                foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $value = $this-&gt;sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $rating_scheme = null;
+                                                                        $rating_value = null;
+                                                                        if (isset($rating['attribs']['']['scheme']))
+                                                                        {
+                                                                                $rating_scheme = $this-&gt;sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        else
+                                                                        {
+                                                                                $rating_scheme = 'urn:simple';
+                                                                        }
+                                                                        if (isset($rating['data']))
+                                                                        {
+                                                                                $rating_value = $this-&gt;sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        $ratings[] =&amp; new $this-&gt;feed-&gt;rating_class($rating_scheme, $rating_value);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($hash['attribs']['']['algo']))
</del><ins>+                                                                if (is_array($ratings))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $algo = $this-&gt;sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $ratings = array_values(SimplePie_Misc::array_unique($ratings));
</ins><span class="cx">                                                                 }
</span><del>-                                                                else
-                                                                {
-                                                                        $algo = 'md5';
-                                                                }
-                                                                $hashes[] = $algo.':'.$value;
</del><span class="cx">                                                         }
</span><del>-                                                        if (is_array($hashes))
</del><ins>+                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $hashes = array_values(SimplePie_Misc::array_unique($hashes));
-                                                        }
-                                                }
-                                                else
-                                                {
-                                                        $hashes = $hashes_parent;
-                                                }
-
-                                                // KEYWORDS
-                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
-                                                {
-                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
-                                                        {
-                                                                $temp = explode(',', $this-&gt;sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
-                                                                foreach ($temp as $word)
</del><ins>+                                                                foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $keywords[] = trim($word);
</del><ins>+                                                                        $rating_scheme = null;
+                                                                        $rating_value = null;
+                                                                        if (isset($rating['attribs']['']['scheme']))
+                                                                        {
+                                                                                $rating_scheme = $this-&gt;sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        else
+                                                                        {
+                                                                                $rating_scheme = 'urn:simple';
+                                                                        }
+                                                                        if (isset($rating['data']))
+                                                                        {
+                                                                                $rating_value = $this-&gt;sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        $ratings[] =&amp; new $this-&gt;feed-&gt;rating_class($rating_scheme, $rating_value);
</ins><span class="cx">                                                                 }
</span><del>-                                                                unset($temp);
-                                                        }
-                                                        if (is_array($keywords))
-                                                        {
-                                                                $keywords = array_values(SimplePie_Misc::array_unique($keywords));
-                                                        }
-                                                }
-                                                elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
-                                                {
-                                                        if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
-                                                        {
-                                                                $temp = explode(',', $this-&gt;sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
-                                                                foreach ($temp as $word)
</del><ins>+                                                                if (is_array($ratings))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $keywords[] = trim($word);
</del><ins>+                                                                        $ratings = array_values(SimplePie_Misc::array_unique($ratings));
</ins><span class="cx">                                                                 }
</span><del>-                                                                unset($temp);
</del><span class="cx">                                                         }
</span><del>-                                                        if (is_array($keywords))
</del><ins>+                                                        else
</ins><span class="cx">                                                         {
</span><del>-                                                                $keywords = array_values(SimplePie_Misc::array_unique($keywords));
</del><ins>+                                                                $ratings = $ratings_parent;
</ins><span class="cx">                                                         }
</span><del>-                                                }
-                                                else
-                                                {
-                                                        $keywords = $keywords_parent;
-                                                }
</del><span class="cx"> 
</span><del>-                                                // PLAYER
-                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
-                                                {
-                                                        $player = $this-&gt;sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
-                                                }
-                                                elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
-                                                {
-                                                        $player = $this-&gt;sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
-                                                }
-                                                else
-                                                {
-                                                        $player = $player_parent;
-                                                }
-
-                                                // RATINGS
-                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
-                                                {
-                                                        foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
</del><ins>+                                                        // RESTRICTIONS
+                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $rating_scheme = null;
-                                                                $rating_value = null;
-                                                                if (isset($rating['attribs']['']['scheme']))
</del><ins>+                                                                foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $rating_scheme = $this-&gt;sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $restriction_relationship = null;
+                                                                        $restriction_type = null;
+                                                                        $restriction_value = null;
+                                                                        if (isset($restriction['attribs']['']['relationship']))
+                                                                        {
+                                                                                $restriction_relationship = $this-&gt;sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($restriction['attribs']['']['type']))
+                                                                        {
+                                                                                $restriction_type = $this-&gt;sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($restriction['data']))
+                                                                        {
+                                                                                $restriction_value = $this-&gt;sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        $restrictions[] =&amp; new $this-&gt;feed-&gt;restriction_class($restriction_relationship, $restriction_type, $restriction_value);
</ins><span class="cx">                                                                 }
</span><del>-                                                                else
</del><ins>+                                                                if (is_array($restrictions))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $rating_scheme = 'urn:simple';
</del><ins>+                                                                        $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($rating['data']))
-                                                                {
-                                                                        $rating_value = $this-&gt;sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                                }
-                                                                $ratings[] =&amp; new $this-&gt;feed-&gt;rating_class($rating_scheme, $rating_value);
</del><span class="cx">                                                         }
</span><del>-                                                        if (is_array($ratings))
</del><ins>+                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $ratings = array_values(SimplePie_Misc::array_unique($ratings));
-                                                        }
-                                                }
-                                                elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
-                                                {
-                                                        foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
-                                                        {
-                                                                $rating_scheme = null;
-                                                                $rating_value = null;
-                                                                if (isset($rating['attribs']['']['scheme']))
</del><ins>+                                                                foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $rating_scheme = $this-&gt;sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $restriction_relationship = null;
+                                                                        $restriction_type = null;
+                                                                        $restriction_value = null;
+                                                                        if (isset($restriction['attribs']['']['relationship']))
+                                                                        {
+                                                                                $restriction_relationship = $this-&gt;sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($restriction['attribs']['']['type']))
+                                                                        {
+                                                                                $restriction_type = $this-&gt;sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        if (isset($restriction['data']))
+                                                                        {
+                                                                                $restriction_value = $this-&gt;sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+                                                                        }
+                                                                        $restrictions[] =&amp; new $this-&gt;feed-&gt;restriction_class($restriction_relationship, $restriction_type, $restriction_value);
</ins><span class="cx">                                                                 }
</span><del>-                                                                else
</del><ins>+                                                                if (is_array($restrictions))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $rating_scheme = 'urn:simple';
</del><ins>+                                                                        $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($rating['data']))
-                                                                {
-                                                                        $rating_value = $this-&gt;sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                                }
-                                                                $ratings[] =&amp; new $this-&gt;feed-&gt;rating_class($rating_scheme, $rating_value);
</del><span class="cx">                                                         }
</span><del>-                                                        if (is_array($ratings))
</del><ins>+                                                        else
</ins><span class="cx">                                                         {
</span><del>-                                                                $ratings = array_values(SimplePie_Misc::array_unique($ratings));
</del><ins>+                                                                $restrictions = $restrictions_parent;
</ins><span class="cx">                                                         }
</span><del>-                                                }
-                                                else
-                                                {
-                                                        $ratings = $ratings_parent;
-                                                }
</del><span class="cx"> 
</span><del>-                                                // RESTRICTIONS
-                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
-                                                {
-                                                        foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
</del><ins>+                                                        // THUMBNAILS
+                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $restriction_relationship = null;
-                                                                $restriction_type = null;
-                                                                $restriction_value = null;
-                                                                if (isset($restriction['attribs']['']['relationship']))
</del><ins>+                                                                foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $restriction_relationship = $this-&gt;sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $thumbnails[] = $this-&gt;sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($restriction['attribs']['']['type']))
</del><ins>+                                                                if (is_array($thumbnails))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $restriction_type = $this-&gt;sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($restriction['data']))
-                                                                {
-                                                                        $restriction_value = $this-&gt;sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                                }
-                                                                $restrictions[] =&amp; new $this-&gt;feed-&gt;restriction_class($restriction_relationship, $restriction_type, $restriction_value);
</del><span class="cx">                                                         }
</span><del>-                                                        if (is_array($restrictions))
</del><ins>+                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
-                                                        }
-                                                }
-                                                elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
-                                                {
-                                                        foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
-                                                        {
-                                                                $restriction_relationship = null;
-                                                                $restriction_type = null;
-                                                                $restriction_value = null;
-                                                                if (isset($restriction['attribs']['']['relationship']))
</del><ins>+                                                                foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $restriction_relationship = $this-&gt;sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $thumbnails[] = $this-&gt;sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($restriction['attribs']['']['type']))
</del><ins>+                                                                if (is_array($thumbnails))
</ins><span class="cx">                                                                 {
</span><del>-                                                                        $restriction_type = $this-&gt;sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                                        $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
</ins><span class="cx">                                                                 }
</span><del>-                                                                if (isset($restriction['data']))
-                                                                {
-                                                                        $restriction_value = $this-&gt;sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                                }
-                                                                $restrictions[] =&amp; new $this-&gt;feed-&gt;restriction_class($restriction_relationship, $restriction_type, $restriction_value);
</del><span class="cx">                                                         }
</span><del>-                                                        if (is_array($restrictions))
</del><ins>+                                                        else
</ins><span class="cx">                                                         {
</span><del>-                                                                $restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
</del><ins>+                                                                $thumbnails = $thumbnails_parent;
</ins><span class="cx">                                                         }
</span><del>-                                                }
-                                                else
-                                                {
-                                                        $restrictions = $restrictions_parent;
-                                                }
</del><span class="cx"> 
</span><del>-                                                // THUMBNAILS
-                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
-                                                {
-                                                        foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
</del><ins>+                                                        // TITLES
+                                                        if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $thumbnails[] = $this-&gt;sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
</del><ins>+                                                                $title = $this-&gt;sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</ins><span class="cx">                                                         }
</span><del>-                                                        if (is_array($thumbnails))
</del><ins>+                                                        elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
</ins><span class="cx">                                                         {
</span><del>-                                                                $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
</del><ins>+                                                                $title = $this-&gt;sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</ins><span class="cx">                                                         }
</span><del>-                                                }
-                                                elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
-                                                {
-                                                        foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
</del><ins>+                                                        else
</ins><span class="cx">                                                         {
</span><del>-                                                                $thumbnails[] = $this-&gt;sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
</del><ins>+                                                                $title = $title_parent;
</ins><span class="cx">                                                         }
</span><del>-                                                        if (is_array($thumbnails))
-                                                        {
-                                                                $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
-                                                        }
-                                                }
-                                                else
-                                                {
-                                                        $thumbnails = $thumbnails_parent;
-                                                }
</del><span class="cx"> 
</span><del>-                                                // TITLES
-                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
-                                                {
-                                                        $title = $this-&gt;sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
</del><ins>+                                                        $this-&gt;data['enclosures'][] =&amp; new $this-&gt;feed-&gt;enclosure_class($url, $type, $length, $this-&gt;feed-&gt;javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width);
</ins><span class="cx">                                                 }
</span><del>-                                                elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
-                                                {
-                                                        $title = $this-&gt;sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
-                                                }
-                                                else
-                                                {
-                                                        $title = $title_parent;
-                                                }
-
-                                                $this-&gt;data['enclosures'][] =&amp; new $this-&gt;feed-&gt;enclosure_class($url, $type, $length, $this-&gt;feed-&gt;javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width);
</del><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -5052,7 +5062,7 @@
</span><span class="cx">                         {
</span><span class="cx">                                 foreach ((array) $this-&gt;data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
</span><span class="cx">                                 {
</span><del>-                                        if (isset($content['attribs']['']['url']))
</del><ins>+                                        if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
</ins><span class="cx">                                         {
</span><span class="cx">                                                 // Attributes
</span><span class="cx">                                                 $bitrate = null;
</span><span class="lines">@@ -5137,8 +5147,10 @@
</span><span class="cx">                                                 {
</span><span class="cx">                                                         $width = $this-&gt;sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
</span><span class="cx">                                                 }
</span><del>-                                                $url = $this-&gt;sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
-
</del><ins>+                                                if (isset($content['attribs']['']['url']))
+                                                {
+                                                        $url = $this-&gt;sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+                                                }
</ins><span class="cx">                                                 // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
</span><span class="cx"> 
</span><span class="cx">                                                 // CAPTIONS
</span><span class="lines">@@ -5580,7 +5592,7 @@
</span><span class="cx">                 {
</span><span class="cx">                         return (float) $return[0]['data'];
</span><span class="cx">                 }
</span><del>-                elseif (($return = $this-&gt;get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) &amp;&amp; preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
</del><ins>+                elseif (($return = $this-&gt;get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) &amp;&amp; preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
</ins><span class="cx">                 {
</span><span class="cx">                         return (float) $match[1];
</span><span class="cx">                 }
</span><span class="lines">@@ -5600,7 +5612,7 @@
</span><span class="cx">                 {
</span><span class="cx">                         return (float) $return[0]['data'];
</span><span class="cx">                 }
</span><del>-                elseif (($return = $this-&gt;get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) &amp;&amp; preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
</del><ins>+                elseif (($return = $this-&gt;get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) &amp;&amp; preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
</ins><span class="cx">                 {
</span><span class="cx">                         return (float) $match[2];
</span><span class="cx">                 }
</span><span class="lines">@@ -6223,7 +6235,7 @@
</span><span class="cx">                 {
</span><span class="cx">                         return (float) $return[0]['data'];
</span><span class="cx">                 }
</span><del>-                elseif (($return = $this-&gt;get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) &amp;&amp; preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
</del><ins>+                elseif (($return = $this-&gt;get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) &amp;&amp; preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
</ins><span class="cx">                 {
</span><span class="cx">                         return (float) $match[1];
</span><span class="cx">                 }
</span><span class="lines">@@ -6243,7 +6255,7 @@
</span><span class="cx">                 {
</span><span class="cx">                         return (float) $return[0]['data'];
</span><span class="cx">                 }
</span><del>-                elseif (($return = $this-&gt;get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) &amp;&amp; preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
</del><ins>+                elseif (($return = $this-&gt;get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) &amp;&amp; preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
</ins><span class="cx">                 {
</span><span class="cx">                         return (float) $match[2];
</span><span class="cx">                 }
</span><span class="lines">@@ -7727,16 +7739,17 @@
</span><span class="cx">                         {
</span><span class="cx">                                 $this-&gt;method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
</span><span class="cx">                                 $url_parts = parse_url($url);
</span><ins>+                                $socket_host = $url_parts['host'];
</ins><span class="cx">                                 if (isset($url_parts['scheme']) &amp;&amp; strtolower($url_parts['scheme']) === 'https')
</span><span class="cx">                                 {
</span><del>-                                        $url_parts['host'] = &quot;ssl://$url_parts[host]&quot;;
</del><ins>+                                        $socket_host = &quot;ssl://$url_parts[host]&quot;;
</ins><span class="cx">                                         $url_parts['port'] = 443;
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!isset($url_parts['port']))
</span><span class="cx">                                 {
</span><span class="cx">                                         $url_parts['port'] = 80;
</span><span class="cx">                                 }
</span><del>-                                $fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout);
</del><ins>+                                $fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout);
</ins><span class="cx">                                 if (!$fp)
</span><span class="cx">                                 {
</span><span class="cx">                                         $this-&gt;error = 'fsockopen error: ' . $errstr;
</span><span class="lines">@@ -8482,7 +8495,7 @@
</span><span class="cx"> 
</span><span class="cx">                                 // Get the length of the extra field
</span><span class="cx">                                 $len = current(unpack('v', substr($this-&gt;compressed_data, $this-&gt;position, 2)));
</span><del>-                                $position += 2;
</del><ins>+                                $this-&gt;position += 2;
</ins><span class="cx"> 
</span><span class="cx">                                 // Check the length of the string is still valid
</span><span class="cx">                                 $this-&gt;min_compressed_size += $len + 4;
</span><span class="lines">@@ -9234,8 +9247,25 @@
</span><span class="cx">                                         $note = 'Unknown Error';
</span><span class="cx">                                         break;
</span><span class="cx">                         }
</span><del>-                        error_log(&quot;$note: $message in $file on line $line&quot;, 0);
</del><ins>+
+                        $log_error = true;
+                        if (!function_exists('error_log'))
+                        {
+                                $log_error = false;
+                        }
+
+                        $log_file = @ini_get('error_log');
+                        if (!empty($log_file) &amp;&amp; ('syslog' != $log_file) &amp;&amp; !@is_writable($log_file))
+                        {
+                                $log_error = false;
+                        }
+
+                        if ($log_error)
+                        {
+                                @error_log(&quot;$note: $message in $file on line $line&quot;, 0);
+                        }
</ins><span class="cx">                 }
</span><ins>+
</ins><span class="cx">                 return $message;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -9432,7 +9462,7 @@
</span><span class="cx">                         return SimplePie_Misc::windows_1252_to_utf8($data);
</span><span class="cx">                 }
</span><span class="cx">                 // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
</span><del>-                elseif (function_exists('mb_convert_encoding') &amp;&amp; @mb_convert_encoding(&quot;\x80&quot;, 'UTF-16BE', $input) !== &quot;\x00\x80&quot; &amp;&amp; ($return = @mb_convert_encoding($data, $output, $input)))
</del><ins>+                elseif (function_exists('mb_convert_encoding') &amp;&amp; @mb_convert_encoding(&quot;\x80&quot;, 'UTF-16BE', $input) !== &quot;\x00\x80&quot; &amp;&amp; in_array($input, mb_list_encodings()) &amp;&amp; ($return = @mb_convert_encoding($data, $output, $input)))
</ins><span class="cx">                 {
</span><span class="cx">                         return $return;
</span><span class="cx">                 }
</span><span class="lines">@@ -9448,6 +9478,17 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Normalize an encoding name
+         *
+         * This is automatically generated by create.php
+         *
+         * To generate it, run `php create.php` on the command line, and copy the
+         * output to replace this function.
+         *
+         * @param string $charset Character set to standardise
+         * @return string Standardised name
+         */
</ins><span class="cx">         function encoding($charset)
</span><span class="cx">         {
</span><span class="cx">                 // Normalization from UTS #22
</span><span class="lines">@@ -9481,7 +9522,6 @@
</span><span class="cx"> 
</span><span class="cx">                         case 'big5':
</span><span class="cx">                         case 'csbig5':
</span><del>-                        case 'xxbig5':
</del><span class="cx">                                 return 'Big5';
</span><span class="cx"> 
</span><span class="cx">                         case 'big5hkscs':
</span><span class="lines">@@ -9637,15 +9677,15 @@
</span><span class="cx">                         case 'isoir85':
</span><span class="cx">                                 return 'ES2';
</span><span class="cx"> 
</span><ins>+                        case 'cseucpkdfmtjapanese':
+                        case 'eucjp':
+                        case 'extendedunixcodepackedformatforjapanese':
+                                return 'EUC-JP';
+
</ins><span class="cx">                         case 'cseucfixwidjapanese':
</span><span class="cx">                         case 'extendedunixcodefixedwidthforjapanese':
</span><span class="cx">                                 return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
</span><span class="cx"> 
</span><del>-                        case 'cseucpkdfmtjapanese':
-                        case 'eucjp':
-                        case 'extendedunixcodepackedformatforjapanese':
-                                return 'Extended_UNIX_Code_Packed_Format_for_Japanese';
-
</del><span class="cx">                         case 'gb18030':
</span><span class="cx">                                 return 'GB18030';
</span><span class="cx"> 
</span><span class="lines">@@ -9723,80 +9763,6 @@
</span><span class="cx">                         case 'ibmthai':
</span><span class="cx">                                 return 'IBM-Thai';
</span><span class="cx"> 
</span><del>-                        case 'ccsid858':
-                        case 'cp858':
-                        case 'ibm858':
-                        case 'pcmultilingual850euro':
-                                return 'IBM00858';
-
-                        case 'ccsid924':
-                        case 'cp924':
-                        case 'ebcdiclatin9euro':
-                        case 'ibm924':
-                                return 'IBM00924';
-
-                        case 'ccsid1140':
-                        case 'cp1140':
-                        case 'ebcdicus37euro':
-                        case 'ibm1140':
-                                return 'IBM01140';
-
-                        case 'ccsid1141':
-                        case 'cp1141':
-                        case 'ebcdicde273euro':
-                        case 'ibm1141':
-                                return 'IBM01141';
-
-                        case 'ccsid1142':
-                        case 'cp1142':
-                        case 'ebcdicdk277euro':
-                        case 'ebcdicno277euro':
-                        case 'ibm1142':
-                                return 'IBM01142';
-
-                        case 'ccsid1143':
-                        case 'cp1143':
-                        case 'ebcdicfi278euro':
-                        case 'ebcdicse278euro':
-                        case 'ibm1143':
-                                return 'IBM01143';
-
-                        case 'ccsid1144':
-                        case 'cp1144':
-                        case 'ebcdicit280euro':
-                        case 'ibm1144':
-                                return 'IBM01144';
-
-                        case 'ccsid1145':
-                        case 'cp1145':
-                        case 'ebcdices284euro':
-                        case 'ibm1145':
-                                return 'IBM01145';
-
-                        case 'ccsid1146':
-                        case 'cp1146':
-                        case 'ebcdicgb285euro':
-                        case 'ibm1146':
-                                return 'IBM01146';
-
-                        case 'ccsid1147':
-                        case 'cp1147':
-                        case 'ebcdicfr297euro':
-                        case 'ibm1147':
-                                return 'IBM01147';
-
-                        case 'ccsid1148':
-                        case 'cp1148':
-                        case 'ebcdicinternational500euro':
-                        case 'ibm1148':
-                                return 'IBM01148';
-
-                        case 'ccsid1149':
-                        case 'cp1149':
-                        case 'ebcdicis871euro':
-                        case 'ibm1149':
-                                return 'IBM01149';
-
</del><span class="cx">                         case 'cp37':
</span><span class="cx">                         case 'csibm37':
</span><span class="cx">                         case 'ebcdiccpca':
</span><span class="lines">@@ -9944,6 +9910,12 @@
</span><span class="cx">                         case 'ibm857':
</span><span class="cx">                                 return 'IBM857';
</span><span class="cx"> 
</span><ins>+                        case 'ccsid858':
+                        case 'cp858':
+                        case 'ibm858':
+                        case 'pcmultilingual850euro':
+                                return 'IBM00858';
+
</ins><span class="cx">                         case '860':
</span><span class="cx">                         case 'cp860':
</span><span class="cx">                         case 'csibm860':
</span><span class="lines">@@ -10046,6 +10018,12 @@
</span><span class="cx">                         case 'ibm918':
</span><span class="cx">                                 return 'IBM918';
</span><span class="cx"> 
</span><ins>+                        case 'ccsid924':
+                        case 'cp924':
+                        case 'ebcdiclatin9euro':
+                        case 'ibm924':
+                                return 'IBM00924';
+
</ins><span class="cx">                         case 'cp1026':
</span><span class="cx">                         case 'csibm1026':
</span><span class="cx">                         case 'ibm1026':
</span><span class="lines">@@ -10054,6 +10032,68 @@
</span><span class="cx">                         case 'ibm1047':
</span><span class="cx">                                 return 'IBM1047';
</span><span class="cx"> 
</span><ins>+                        case 'ccsid1140':
+                        case 'cp1140':
+                        case 'ebcdicus37euro':
+                        case 'ibm1140':
+                                return 'IBM01140';
+
+                        case 'ccsid1141':
+                        case 'cp1141':
+                        case 'ebcdicde273euro':
+                        case 'ibm1141':
+                                return 'IBM01141';
+
+                        case 'ccsid1142':
+                        case 'cp1142':
+                        case 'ebcdicdk277euro':
+                        case 'ebcdicno277euro':
+                        case 'ibm1142':
+                                return 'IBM01142';
+
+                        case 'ccsid1143':
+                        case 'cp1143':
+                        case 'ebcdicfi278euro':
+                        case 'ebcdicse278euro':
+                        case 'ibm1143':
+                                return 'IBM01143';
+
+                        case 'ccsid1144':
+                        case 'cp1144':
+                        case 'ebcdicit280euro':
+                        case 'ibm1144':
+                                return 'IBM01144';
+
+                        case 'ccsid1145':
+                        case 'cp1145':
+                        case 'ebcdices284euro':
+                        case 'ibm1145':
+                                return 'IBM01145';
+
+                        case 'ccsid1146':
+                        case 'cp1146':
+                        case 'ebcdicgb285euro':
+                        case 'ibm1146':
+                                return 'IBM01146';
+
+                        case 'ccsid1147':
+                        case 'cp1147':
+                        case 'ebcdicfr297euro':
+                        case 'ibm1147':
+                                return 'IBM01147';
+
+                        case 'ccsid1148':
+                        case 'cp1148':
+                        case 'ebcdicinternational500euro':
+                        case 'ibm1148':
+                                return 'IBM01148';
+
+                        case 'ccsid1149':
+                        case 'cp1149':
+                        case 'ebcdicis871euro':
+                        case 'ibm1149':
+                                return 'IBM01149';
+
</ins><span class="cx">                         case 'csiso143iecp271':
</span><span class="cx">                         case 'iecp271':
</span><span class="cx">                         case 'isoir143':
</span><span class="lines">@@ -10596,11 +10636,6 @@
</span><span class="cx">                         case 'sen850200c':
</span><span class="cx">                                 return 'SEN_850200_C';
</span><span class="cx"> 
</span><del>-                        case 'csshiftjis':
-                        case 'mskanji':
-                        case 'shiftjis':
-                                return 'Shift_JIS';
-
</del><span class="cx">                         case 'csiso102t617bit':
</span><span class="cx">                         case 'isoir102':
</span><span class="cx">                         case 't617bit':
</span><span class="lines">@@ -10699,7 +10734,10 @@
</span><span class="cx">                         case 'viscii':
</span><span class="cx">                                 return 'VISCII';
</span><span class="cx"> 
</span><ins>+                        case 'csshiftjis':
</ins><span class="cx">                         case 'cswindows31j':
</span><ins>+                        case 'mskanji':
+                        case 'shiftjis':
</ins><span class="cx">                         case 'windows31j':
</span><span class="cx">                                 return 'Windows-31J';
</span><span class="cx"> 
</span><span class="lines">@@ -11360,6 +11398,58 @@
</span><span class="cx"> }
</span><span class="cx">                 &lt;?php
</span><span class="cx">         }
</span><ins>+
+
+
+        /**
+         * Format debugging information
+         */
+        function debug($sp)
+        {
+                $info = 'SimplePie ' . SIMPLEPIE_VERSION . ' Build ' . SIMPLEPIE_BUILD . &quot;\n&quot;;
+                $info .= 'PHP ' . PHP_VERSION . &quot;\n&quot;;
+                if ($sp-&gt;error() !== null)
+                {
+                        $info .= 'Error occurred: ' . $sp-&gt;error() . &quot;\n&quot;;
+                }
+                else
+                {
+                        $info .= &quot;No error found.\n&quot;;
+                }
+                $info .= &quot;Extensions:\n&quot;;
+                $extensions = array('pcre', 'curl', 'zlib', 'mbstring', 'iconv', 'xmlreader', 'xml');
+                foreach ($extensions as $ext)
+                {
+                        if (extension_loaded($ext))
+                        {
+                                $info .= &quot;    $ext loaded\n&quot;;
+                                switch ($ext)
+                                {
+                                        case 'pcre':
+                                                $info .= '      Version ' . PCRE_VERSION . &quot;\n&quot;;
+                                                break;
+                                        case 'curl':
+                                                $version = curl_version();
+                                                $info .= '      Version ' . $version['version'] . &quot;\n&quot;;
+                                                break;
+                                        case 'mbstring':
+                                                $info .= '      Overloading: ' . mb_get_info('func_overload') . &quot;\n&quot;;
+                                                break;
+                                        case 'iconv':
+                                                $info .= '      Version ' . ICONV_VERSION . &quot;\n&quot;;
+                                                break;
+                                        case 'xml':
+                                                $info .= '      Version ' . LIBXML_DOTTED_VERSION . &quot;\n&quot;;
+                                                break;
+                                }
+                        }
+                        else
+                        {
+                                $info .= &quot;    $ext not loaded\n&quot;;
+                        }
+                }
+                return $info;
+        }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -11831,14 +11921,135 @@
</span><span class="cx">         /**
</span><span class="cx">          * Replace invalid character with percent encoding
</span><span class="cx">          *
</span><del>-         * @access private
</del><span class="cx">          * @param string $string Input string
</span><span class="cx">          * @param string $valid_chars Valid characters
</span><span class="cx">          * @param int $case Normalise case
</span><span class="cx">          * @return string
</span><span class="cx">          */
</span><del>-        function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE)
</del><ins>+        function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE, $iprivate = false)
</ins><span class="cx">         {
</span><ins>+                // Normalize as many pct-encoded sections as possible
+                $string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array(&amp;$this, 'remove_iunreserved_percent_encoded'), $string);
+
+                // Replace invalid percent characters
+                $string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string);
+
+                // Add unreserved and % to $valid_chars (the latter is safe because all
+                // pct-encoded sections are now valid).
+                $valid_chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%';
+
+                // Now replace any bytes that aren't allowed with their pct-encoded versions
+                $position = 0;
+                $strlen = strlen($string);
+                while (($position += strspn($string, $valid_chars, $position)) &lt; $strlen)
+                {
+                        $value = ord($string[$position]);
+
+                        // Start position
+                        $start = $position;
+
+                        // By default we are valid
+                        $valid = true;
+
+                        // No one byte sequences are valid due to the while.
+                        // Two byte sequence:
+                        if (($value &amp; 0xE0) === 0xC0)
+                        {
+                                $character = ($value &amp; 0x1F) &lt;&lt; 6;
+                                $length = 2;
+                                $remaining = 1;
+                        }
+                        // Three byte sequence:
+                        elseif (($value &amp; 0xF0) === 0xE0)
+                        {
+                                $character = ($value &amp; 0x0F) &lt;&lt; 12;
+                                $length = 3;
+                                $remaining = 2;
+                        }
+                        // Four byte sequence:
+                        elseif (($value &amp; 0xF8) === 0xF0)
+                        {
+                                $character = ($value &amp; 0x07) &lt;&lt; 18;
+                                $length = 4;
+                                $remaining = 3;
+                        }
+                        // Invalid byte:
+                        else
+                        {
+                                $valid = false;
+                                $length = 1;
+                                $remaining = 0;
+                        }
+
+                        if ($remaining)
+                        {
+                                if ($position + $length &lt;= $strlen)
+                                {
+                                        for ($position++; $remaining; $position++)
+                                        {
+                                                $value = ord($string[$position]);
+
+                                                // Check that the byte is valid, then add it to the character:
+                                                if (($value &amp; 0xC0) === 0x80)
+                                                {
+                                                        $character |= ($value &amp; 0x3F) &lt;&lt; (--$remaining * 6);
+                                                }
+                                                // If it is invalid, count the sequence as invalid and reprocess the current byte:
+                                                else
+                                                {
+                                                        $valid = false;
+                                                        $position--;
+                                                        break;
+                                                }
+                                        }
+                                }
+                                else
+                                {
+                                        $position = $strlen - 1;
+                                        $valid = false;
+                                }
+                        }
+
+                        // Percent encode anything invalid or not in ucschar
+                        if (
+                                // Invalid sequences
+                                !$valid
+                                // Non-shortest form sequences are invalid
+                                || $length &gt; 1 &amp;&amp; $character &lt;= 0x7F
+                                || $length &gt; 2 &amp;&amp; $character &lt;= 0x7FF
+                                || $length &gt; 3 &amp;&amp; $character &lt;= 0xFFFF
+                                // Outside of range of ucschar codepoints
+                                // Noncharacters
+                                || ($character &amp; 0xFFFE) === 0xFFFE
+                                || $character &gt;= 0xFDD0 &amp;&amp; $character &lt;= 0xFDEF
+                                || (
+                                        // Everything else not in ucschar
+                                           $character &gt; 0xD7FF &amp;&amp; $character &lt; 0xF900
+                                        || $character &lt; 0xA0
+                                        || $character &gt; 0xEFFFD
+                                )
+                                &amp;&amp; (
+                                        // Everything not in iprivate, if it applies
+                                           !$iprivate
+                                        || $character &lt; 0xE000
+                                        || $character &gt; 0x10FFFD
+                                )
+                        )
+                        {
+                                // If we were a character, pretend we weren't, but rather an error.
+                                if ($valid)
+                                        $position--;
+
+                                for ($j = $start; $j &lt;= $position; $j++)
+                                {
+                                        $string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1);
+                                        $j += 2;
+                                        $position += 2;
+                                        $strlen += 2;
+                                }
+                        }
+                }
+
</ins><span class="cx">                 // Normalise case
</span><span class="cx">                 if ($case &amp; SIMPLEPIE_LOWERCASE)
</span><span class="cx">                 {
</span><span class="lines">@@ -11849,61 +12060,148 @@
</span><span class="cx">                         $string = strtoupper($string);
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                // Store position and string length (to avoid constantly recalculating this)
-                $position = 0;
-                $strlen = strlen($string);
</del><ins>+                return $string;
+        }
</ins><span class="cx"> 
</span><del>-                // Loop as long as we have invalid characters, advancing the position to the next invalid character
-                while (($position += strspn($string, $valid_chars, $position)) &lt; $strlen)
</del><ins>+        /**
+         * Callback function for preg_replace_callback.
+         *
+         * Removes sequences of percent encoded bytes that represent UTF-8
+         * encoded characters in iunreserved
+         *
+         * @access private
+         * @param array $match PCRE match
+         * @return string Replacement
+         */
+        function remove_iunreserved_percent_encoded($match)
+        {
+                // As we just have valid percent encoded sequences we can just explode
+                // and ignore the first member of the returned array (an empty string).
+                $bytes = explode('%', $match[0]);
+
+                // Initialize the new string (this is what will be returned) and that
+                // there are no bytes remaining in the current sequence (unsurprising
+                // at the first byte!).
+                $string = '';
+                $remaining = 0;
+
+                // Loop over each and every byte, and set $value to its value
+                for ($i = 1, $len = count($bytes); $i &lt; $len; $i++)
</ins><span class="cx">                 {
</span><del>-                        // If we have a % character
-                        if ($string[$position] === '%')
</del><ins>+                        $value = hexdec($bytes[$i]);
+
+                        // If we're the first byte of sequence:
+                        if (!$remaining)
</ins><span class="cx">                         {
</span><del>-                                // If we have a pct-encoded section
-                                if ($position + 2 &lt; $strlen &amp;&amp; strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2)
</del><ins>+                                // Start position
+                                $start = $i;
+
+                                // By default we are valid
+                                $valid = true;
+
+                                // One byte sequence:
+                                if ($value &lt;= 0x7F)
</ins><span class="cx">                                 {
</span><del>-                                        // Get the the represented character
-                                        $chr = chr(hexdec(substr($string, $position + 1, 2)));
</del><ins>+                                        $character = $value;
+                                        $length = 1;
+                                }
+                                // Two byte sequence:
+                                elseif (($value &amp; 0xE0) === 0xC0)
+                                {
+                                        $character = ($value &amp; 0x1F) &lt;&lt; 6;
+                                        $length = 2;
+                                        $remaining = 1;
+                                }
+                                // Three byte sequence:
+                                elseif (($value &amp; 0xF0) === 0xE0)
+                                {
+                                        $character = ($value &amp; 0x0F) &lt;&lt; 12;
+                                        $length = 3;
+                                        $remaining = 2;
+                                }
+                                // Four byte sequence:
+                                elseif (($value &amp; 0xF8) === 0xF0)
+                                {
+                                        $character = ($value &amp; 0x07) &lt;&lt; 18;
+                                        $length = 4;
+                                        $remaining = 3;
+                                }
+                                // Invalid byte:
+                                else
+                                {
+                                        $valid = false;
+                                        $remaining = 0;
+                                }
+                        }
+                        // Continuation byte:
+                        else
+                        {
+                                // Check that the byte is valid, then add it to the character:
+                                if (($value &amp; 0xC0) === 0x80)
+                                {
+                                        $remaining--;
+                                        $character |= ($value &amp; 0x3F) &lt;&lt; ($remaining * 6);
+                                }
+                                // If it is invalid, count the sequence as invalid and reprocess the current byte as the start of a sequence:
+                                else
+                                {
+                                        $valid = false;
+                                        $remaining = 0;
+                                        $i--;
+                                }
+                        }
</ins><span class="cx"> 
</span><del>-                                        // If the character is valid, replace the pct-encoded with the actual character while normalising case
-                                        if (strpos($valid_chars, $chr) !== false)
</del><ins>+                        // If we've reached the end of the current byte sequence, append it to Unicode::$data
+                        if (!$remaining)
+                        {
+                                // Percent encode anything invalid or not in iunreserved
+                                if (
+                                        // Invalid sequences
+                                        !$valid
+                                        // Non-shortest form sequences are invalid
+                                        || $length &gt; 1 &amp;&amp; $character &lt;= 0x7F
+                                        || $length &gt; 2 &amp;&amp; $character &lt;= 0x7FF
+                                        || $length &gt; 3 &amp;&amp; $character &lt;= 0xFFFF
+                                        // Outside of range of iunreserved codepoints
+                                        || $character &lt; 0x2D
+                                        || $character &gt; 0xEFFFD
+                                        // Noncharacters
+                                        || ($character &amp; 0xFFFE) === 0xFFFE
+                                        || $character &gt;= 0xFDD0 &amp;&amp; $character &lt;= 0xFDEF
+                                        // Everything else not in iunreserved (this is all BMP)
+                                        || $character === 0x2F
+                                        || $character &gt; 0x39 &amp;&amp; $character &lt; 0x41
+                                        || $character &gt; 0x5A &amp;&amp; $character &lt; 0x61
+                                        || $character &gt; 0x7A &amp;&amp; $character &lt; 0x7E
+                                        || $character &gt; 0x7E &amp;&amp; $character &lt; 0xA0
+                                        || $character &gt; 0xD7FF &amp;&amp; $character &lt; 0xF900
+                                )
+                                {
+                                        for ($j = $start; $j &lt;= $i; $j++)
</ins><span class="cx">                                         {
</span><del>-                                                if ($case &amp; SIMPLEPIE_LOWERCASE)
-                                                {
-                                                        $chr = strtolower($chr);
-                                                }
-                                                elseif ($case &amp; SIMPLEPIE_UPPERCASE)
-                                                {
-                                                        $chr = strtoupper($chr);
-                                                }
-                                                $string = substr_replace($string, $chr, $position, 3);
-                                                $strlen -= 2;
-                                                $position++;
</del><ins>+                                                $string .= '%' . strtoupper($bytes[$j]);
</ins><span class="cx">                                         }
</span><del>-
-                                        // Otherwise just normalise the pct-encoded to uppercase
-                                        else
-                                        {
-                                                $string = substr_replace($string, strtoupper(substr($string, $position + 1, 2)), $position + 1, 2);
-                                                $position += 3;
-                                        }
</del><span class="cx">                                 }
</span><del>-                                // If we don't have a pct-encoded section, just replace the % with its own esccaped form
</del><span class="cx">                                 else
</span><span class="cx">                                 {
</span><del>-                                        $string = substr_replace($string, '%25', $position, 1);
-                                        $strlen += 2;
-                                        $position += 3;
</del><ins>+                                        for ($j = $start; $j &lt;= $i; $j++)
+                                        {
+                                                $string .= chr(hexdec($bytes[$j]));
+                                        }
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        // If we have an invalid character, change into its pct-encoded form
-                        else
</del><ins>+                }
+
+                // If we have any bytes left over they are invalid (i.e., we are
+                // mid-way through a multi-byte sequence)
+                if ($remaining)
+                {
+                        for ($j = $start; $j &lt; $len; $j++)
</ins><span class="cx">                         {
</span><del>-                                $replacement = sprintf(&quot;%%%02X&quot;, ord($string[$position]));
-                                $string = str_replace($string[$position], $replacement, $string);
-                                $strlen = strlen($string);
</del><ins>+                                $string .= '%' . strtoupper($bytes[$j]);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><ins>+
</ins><span class="cx">                 return $string;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -12130,7 +12428,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 else
</span><span class="cx">                 {
</span><del>-                        $this-&gt;query = $this-&gt;replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&amp;\'()*+,;=:@/?');
</del><ins>+                        $this-&gt;query = $this-&gt;replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?&amp;=');
</ins><span class="cx">                 }
</span><span class="cx">                 $this-&gt;valid[__FUNCTION__] = true;
</span><span class="cx">                 return true;
</span><span class="lines">@@ -13933,7 +14231,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 else
</span><span class="cx">                 {
</span><del>-                        $this-&gt;state = 'standalone_name';
</del><ins>+                        $this-&gt;state = false;
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -13947,7 +14245,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 else
</span><span class="cx">                 {
</span><del>-                        $this-&gt;state = false;
</del><ins>+                        $this-&gt;state = 'standalone_name';
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -14425,7 +14723,7 @@
</span><span class="cx">                                         case constant('XMLReader::END_ELEMENT'):
</span><span class="cx">                                                 if ($xml-&gt;namespaceURI !== '')
</span><span class="cx">                                                 {
</span><del>-                                                        $tagName = &quot;{$xml-&gt;namespaceURI}{$this-&gt;separator}{$xml-&gt;localName}&quot;;
</del><ins>+                                                        $tagName = $xml-&gt;namespaceURI . $this-&gt;separator . $xml-&gt;localName;
</ins><span class="cx">                                                 }
</span><span class="cx">                                                 else
</span><span class="cx">                                                 {
</span><span class="lines">@@ -14437,7 +14735,7 @@
</span><span class="cx">                                                 $empty = $xml-&gt;isEmptyElement;
</span><span class="cx">                                                 if ($xml-&gt;namespaceURI !== '')
</span><span class="cx">                                                 {
</span><del>-                                                        $tagName = &quot;{$xml-&gt;namespaceURI}{$this-&gt;separator}{$xml-&gt;localName}&quot;;
</del><ins>+                                                        $tagName = $xml-&gt;namespaceURI . $this-&gt;separator . $xml-&gt;localName;
</ins><span class="cx">                                                 }
</span><span class="cx">                                                 else
</span><span class="cx">                                                 {
</span><span class="lines">@@ -14448,7 +14746,7 @@
</span><span class="cx">                                                 {
</span><span class="cx">                                                         if ($xml-&gt;namespaceURI !== '')
</span><span class="cx">                                                         {
</span><del>-                                                                $attrName = &quot;{$xml-&gt;namespaceURI}{$this-&gt;separator}{$xml-&gt;localName}&quot;;
</del><ins>+                                                                $attrName = $xml-&gt;namespaceURI . $this-&gt;separator . $xml-&gt;localName;
</ins><span class="cx">                                                         }
</span><span class="cx">                                                         else
</span><span class="cx">                                                         {
</span><span class="lines">@@ -14913,7 +15211,7 @@
</span><span class="cx">                                                                         }
</span><span class="cx">                                                                         else
</span><span class="cx">                                                                         {
</span><del>-                                                                                trigger_error(&quot;$this-&gt;cache_location is not writeable&quot;, E_USER_WARNING);
</del><ins>+                                                                                trigger_error(&quot;$this-&gt;cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.&quot;, E_USER_WARNING);
</ins><span class="cx">                                                                         }
</span><span class="cx">                                                                 }
</span><span class="cx">                                                         }
</span></span></pre>
</div>
</div>

</body>
</html>