MDL-23980 importing latest 1.3dev - this should fix the url encode problem
authorPetr Skoda <skodak@moodle.org>
Sat, 28 Aug 2010 13:46:54 +0000 (13:46 +0000)
committerPetr Skoda <skodak@moodle.org>
Sat, 28 Aug 2010 13:46:54 +0000 (13:46 +0000)
lib/simplepie/README.markdown [new file with mode: 0644]
lib/simplepie/moodle_simplepie.php
lib/simplepie/readme_moodle.txt
lib/simplepie/simplepie.class.php [moved from lib/simplepie/simplepie.inc with 99% similarity]

diff --git a/lib/simplepie/README.markdown b/lib/simplepie/README.markdown
new file mode 100644 (file)
index 0000000..c432b9e
--- /dev/null
@@ -0,0 +1,85 @@
+# SimplePie
+
+## Authors and contributors
+### Current
+* [Ryan McCue](http://ryanmccue.info) (Maintainer, support)
+
+### Alumni
+* [Ryan Parman](http://ryanparman.com) (Creator, developer, evangelism, support)
+* [Geoffrey Sneddon](http://gsnedders.com) (Lead developer)
+* [Michael Shipley](http://michaelpshipley.com) (Submitter of patches, support)
+* [Steve Minutillo](http://minutillo.com/steve/) (Submitter of patches)
+
+### Contributors
+For a complete list of contributors:
+
+1. Pull down the latest SimplePie code
+2. In the `simplepie` directory, run `git shortlog -ns`
+
+
+## Requirements
+* PHP 5.1.4 or newer
+* libxml2 (certain 2.7.x releases are too buggy for words, and will crash)
+* Either the iconv or mbstring extension
+* cURL or fsockopen()
+* PCRE support
+
+If you're looking for PHP 4.x support, pull the "1.2" tag, as that's the last version to support PHP 4.x.
+
+
+## License
+[New BSD license](http://www.opensource.org/licenses/bsd-license.php)
+
+
+## Project status
+SimplePie is currently maintained by Ryan McCue.
+
+SimplePie is currently in "low-power mode." If the community decides that SimplePie is a valuable tool, then the community will come together to maintain it into the future.
+
+If you're interested in getting involved with SimplePie, please get in touch with Ryan McCue.
+
+
+## Roadmap
+SimplePie 1.3 should be a thoughtful reduction of features. Remove some bloat, slim it down, and break it into smaller, more manageable chunks.
+
+Removing PHP 4.x support will certainly help with the slimming. It will also help avoid certain issues that frequently crop up with PHP 4.x. The PHP5-only migration is underway, but there is still quite a bit of work before it's "clean."
+
+
+## What comes in the package?
+1. `simplepie.inc` - The SimplePie library.  This is all that's required for your pages.
+2. `README.markdown` - This document.
+3. `LICENSE.txt` - A copy of the BSD license.
+4. `compatibility_test/` - The SimplePie compatibility test that checks your server for required settings.
+5. `demo/` - A basic feed reader demo that shows off some of SimplePie's more noticable features.
+6. `idn/` - A third-party library that SimplePie can optionally use to understand Internationalized Domain Names (IDNs).
+7. `test/` - SimplePie's unit test suite.
+
+
+## To start the demo
+1. Upload this package to your webserver.
+2. Make sure that the cache folder inside of the demo folder is server-writable.
+3. Navigate your browser to the demo folder.
+
+
+## Need support?
+For further setup and install documentation, function references, etc., visit:
+[http://simplepie.org/wiki/](http://simplepie.org/wiki/)
+
+For bug reports and feature requests, visit:
+[http://github.com/rmccue/simplepie/issues](http://github.com/rmccue/simplepie/issues)
+
+Support mailing list -- powered by users, for users.
+[http://tech.groups.yahoo.com/group/simplepie-support/](http://tech.groups.yahoo.com/group/simplepie-support/)
+
+
+## Recently removed
+The following have recently been removed:
+
+* Parameters for SimplePie::__construct()
+* add_to_*
+* display_cached_file
+* enable_xml_dump
+* get_favicon
+* set_favicon_handler
+* subscribe_* (except subscribe_url)
+* utf8_bad_replace
index 2ab4ff6..8c4d562 100644 (file)
@@ -31,7 +31,7 @@ require_once($CFG->libdir.'/filelib.php');
 // PLEASE NOTE: we use the simplepie class _unmodified_
 // through the joys of OO. Distros are free to use their stock
 // version of this file.
-require_once($CFG->libdir.'/simplepie/simplepie.inc');
+require_once($CFG->libdir.'/simplepie/simplepie.class.php');
 
 /**
  * Moodle Customised version of the SimplePie class
index eb1d73a..28bfa76 100644 (file)
@@ -1,10 +1,10 @@
 Description of SimplePie v1.3dev library import into Moodle
 
-Obtained from http://simplepie.org/downloads/ - 009bbd51322d037d21e3e3f4db2ec0a187d31836
+Obtained from http://github.com/simplepie/simplepie/commit/798f4674468316b8cc70fe8de73034c072dbdc15
 
 Changes:
   * None. This import contains _NO_CHANGES_ to the simplepie.inc file, changes are
     controlled through OO extension of the classes instead.
 
 Dan Poltawski <talktodan@gmail.com>
-
+Petr Skoda
similarity index 99%
rename from lib/simplepie/simplepie.inc
rename to lib/simplepie/simplepie.class.php
index b87cbcd..2aeb1ff 100644 (file)
@@ -1449,7 +1449,7 @@ class SimplePie
        public function init()
        {
                // Check absolute bare minimum requirements.
-               if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre'))
+               if ((function_exists('version_compare') && version_compare(PHP_VERSION, '5.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre'))
                {
                        return false;
                }
@@ -1764,15 +1764,7 @@ class SimplePie
                        $this->multifeed_objects = array();
                        foreach ($this->multifeed_url as $url)
                        {
-                               if (SIMPLEPIE_PHP5)
-                               {
-                                       // This keyword needs to defy coding standards for PHP4 compatibility
-                                       $this->multifeed_objects[$i] = clone($this);
-                               }
-                               else
-                               {
-                                       $this->multifeed_objects[$i] = $this;
-                               }
+                               $this->multifeed_objects[$i] = clone $this;
                                $this->multifeed_objects[$i]->set_feed_url($url);
                                $success |= $this->multifeed_objects[$i]->init();
                                $i++;
@@ -3024,6 +3016,11 @@ class SimplePie_Item
                {
                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
                }
+               elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
+               {
+                       return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
+               }
+
                elseif (!$description_only)
                {
                        return $this->get_content(true);
@@ -3388,7 +3385,7 @@ class SimplePie_Item
                {
                        return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
                }
-               elseif (($date = $this->get_date('U')) !== null)
+               elseif (($date = $this->get_date('U')) !== null && $date !== false)
                {
                        return strftime($date_format, $date);
                }
@@ -3813,16 +3810,16 @@ class SimplePie_Item
                                        $temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
                                        if (sizeof($temp) > 0)
                                        {
-                                               (int) $seconds = array_pop($temp);
+                                               $seconds = (int) array_pop($temp);
                                        }
                                        if (sizeof($temp) > 0)
                                        {
-                                               (int) $minutes = array_pop($temp);
+                                               $minutes = (int) array_pop($temp);
                                                $seconds += $minutes * 60;
                                        }
                                        if (sizeof($temp) > 0)
                                        {
-                                               (int) $hours = array_pop($temp);
+                                               $hours = (int) array_pop($temp);
                                                $seconds += $hours * 3600;
                                        }
                                        unset($temp);
@@ -4801,7 +4798,7 @@ class SimplePie_Item
                        {
                                foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
                                {
-                                       if (isset($content['attribs']['']['url']))
+                                       if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
                                        {
                                                // Attributes
                                                $bitrate = null;
@@ -4886,8 +4883,10 @@ class SimplePie_Item
                                                {
                                                        $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
                                                }
-                                               $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
-
+                                               if (isset($content['attribs']['']['url']))
+                                               {
+                                                       $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+                                               }
                                                // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
 
                                                // CAPTIONS
@@ -7368,7 +7367,7 @@ class SimplePie_File
                                                {
                                                        $this->redirects++;
                                                        $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
-                                                       return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
+                                                       return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
                                                }
                                        }
                                }
@@ -7449,7 +7448,7 @@ class SimplePie_File
                                                        {
                                                                $this->redirects++;
                                                                $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
-                                                               return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
+                                                               return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
                                                        }
                                                        if (isset($this->headers['content-encoding']))
                                                        {
@@ -8311,21 +8310,7 @@ class SimplePie_Cache_File
                        }
 
                        $data = serialize($data);
-
-                       if (function_exists('file_put_contents'))
-                       {
-                               return (bool) file_put_contents($this->name, $data);
-                       }
-                       else
-                       {
-                               $fp = fopen($this->name, 'wb');
-                               if ($fp)
-                               {
-                                       fwrite($fp, $data);
-                                       fclose($fp);
-                                       return true;
-                               }
-                       }
+                       return (bool) file_put_contents($this->name, $data);
                }
                return false;
        }
@@ -8456,7 +8441,7 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB
        public function __construct($mysql_location, $name, $extension)
        {
                $host = $mysql_location->get_host();
-               if (SimplePie_Misc::stripos($host, 'unix(') === 0 && substr($host, -1) === ')')
+               if (stripos($host, 'unix(') === 0 && substr($host, -1) === ')')
                {
                        $server = ':' . substr($host, 5, -1);
                }
@@ -8529,11 +8514,7 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB
 
                        if (is_a($data, 'SimplePie'))
                        {
-                               if (SIMPLEPIE_PHP5)
-                               {
-                                       // This keyword needs to defy coding standards for PHP4 compatibility
-                                       $data = clone($data);
-                               }
+                               $data = clone $data;
 
                                $prepared = $this->prepare_simplepie_object_for_cache($data);
 
@@ -9015,7 +8996,7 @@ class SimplePie_Misc
                }
 
                // This is first, as behaviour of this is completely predictable
-               if ($input === 'Windows-1252' && $output === 'UTF-8')
+               if ($input === 'windows-1252' && $output === 'UTF-8')
                {
                        return SimplePie_Misc::windows_1252_to_utf8($data);
                }
@@ -9036,6 +9017,17 @@ class SimplePie_Misc
                }
        }
 
+       /**
+        * 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
+        */
        public static function encoding($charset)
        {
                // Normalization from UTS #22
@@ -9069,7 +9061,6 @@ class SimplePie_Misc
 
                        case 'big5':
                        case 'csbig5':
-                       case 'xxbig5':
                                return 'Big5';
 
                        case 'big5hkscs':
@@ -9225,14 +9216,14 @@ class SimplePie_Misc
                        case 'isoir85':
                                return 'ES2';
 
-                       case 'cseucfixwidjapanese':
-                       case 'extendedunixcodefixedwidthforjapanese':
-                               return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
-
                        case 'cseucpkdfmtjapanese':
                        case 'eucjp':
                        case 'extendedunixcodepackedformatforjapanese':
-                               return 'Extended_UNIX_Code_Packed_Format_for_Japanese';
+                               return 'EUC-JP';
+
+                       case 'cseucfixwidjapanese':
+                       case 'extendedunixcodefixedwidthforjapanese':
+                               return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
 
                        case 'gb18030':
                                return 'GB18030';
@@ -9311,80 +9302,6 @@ class SimplePie_Misc
                        case 'ibmthai':
                                return 'IBM-Thai';
 
-                       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';
-
                        case 'cp37':
                        case 'csibm37':
                        case 'ebcdiccpca':
@@ -9532,6 +9449,12 @@ class SimplePie_Misc
                        case 'ibm857':
                                return 'IBM857';
 
+                       case 'ccsid858':
+                       case 'cp858':
+                       case 'ibm858':
+                       case 'pcmultilingual850euro':
+                               return 'IBM00858';
+
                        case '860':
                        case 'cp860':
                        case 'csibm860':
@@ -9634,6 +9557,12 @@ class SimplePie_Misc
                        case 'ibm918':
                                return 'IBM918';
 
+                       case 'ccsid924':
+                       case 'cp924':
+                       case 'ebcdiclatin9euro':
+                       case 'ibm924':
+                               return 'IBM00924';
+
                        case 'cp1026':
                        case 'csibm1026':
                        case 'ibm1026':
@@ -9642,6 +9571,68 @@ class SimplePie_Misc
                        case 'ibm1047':
                                return 'IBM1047';
 
+                       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';
+
                        case 'csiso143iecp271':
                        case 'iecp271':
                        case 'isoir143':
@@ -10184,11 +10175,6 @@ class SimplePie_Misc
                        case 'sen850200c':
                                return 'SEN_850200_C';
 
-                       case 'csshiftjis':
-                       case 'mskanji':
-                       case 'shiftjis':
-                               return 'Shift_JIS';
-
                        case 'csiso102t617bit':
                        case 'isoir102':
                        case 't617bit':
@@ -10287,7 +10273,10 @@ class SimplePie_Misc
                        case 'viscii':
                                return 'VISCII';
 
+                       case 'csshiftjis':
                        case 'cswindows31j':
+                       case 'mskanji':
+                       case 'shiftjis':
                        case 'windows31j':
                                return 'Windows-31J';
 
@@ -10730,49 +10719,6 @@ class SimplePie_Misc
                }
        }
 
-       /**
-        * Re-implementation of PHP 5's stripos()
-        *
-        * Returns the numeric position of the first occurrence of needle in the
-        * haystack string.
-        *
-        * @static
-        * @access string
-        * @param object $haystack
-        * @param string $needle Note that the needle may be a string of one or more
-        *     characters. If needle is not a string, it is converted to an integer
-        *     and applied as the ordinal value of a character.
-        * @param int $offset The optional offset parameter allows you to specify which
-        *     character in haystack to start searching. The position returned is still
-        *     relative to the beginning of haystack.
-        * @return bool If needle is not found, stripos() will return boolean false.
-        */
-       public static function stripos($haystack, $needle, $offset = 0)
-       {
-               if (function_exists('stripos'))
-               {
-                       return stripos($haystack, $needle, $offset);
-               }
-               else
-               {
-                       if (is_string($needle))
-                       {
-                               $needle = strtolower($needle);
-                       }
-                       elseif (is_int($needle) || is_bool($needle) || is_double($needle))
-                       {
-                               $needle = strtolower(chr($needle));
-                       }
-                       else
-                       {
-                               trigger_error('needle is not a string or an integer', E_USER_WARNING);
-                               return false;
-                       }
-
-                       return strpos(strtolower($haystack), $needle, $offset);
-               }
-       }
-
        /**
         * Similar to parse_str()
         *
@@ -11718,7 +11664,7 @@ class SimplePie_IRI
                }
                else
                {
-                       $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?');
+                       $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$\'()*+,;:@/?&=');
                }
                $this->valid[__FUNCTION__] = true;
                return true;
@@ -14013,7 +13959,7 @@ class SimplePie_Parser
                                        case constant('XMLReader::END_ELEMENT'):
                                                if ($xml->namespaceURI !== '')
                                                {
-                                                       $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
+                                                       $tagName = $xml->namespaceURI . $this->separator . $xml->localName;
                                                }
                                                else
                                                {
@@ -14025,7 +13971,7 @@ class SimplePie_Parser
                                                $empty = $xml->isEmptyElement;
                                                if ($xml->namespaceURI !== '')
                                                {
-                                                       $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
+                                                       $tagName = $xml->namespaceURI . $this->separator . $xml->localName;
                                                }
                                                else
                                                {
@@ -14036,7 +13982,7 @@ class SimplePie_Parser
                                                {
                                                        if ($xml->namespaceURI !== '')
                                                        {
-                                                               $attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
+                                                               $attrName = $xml->namespaceURI . $this->separator . $xml->localName;
                                                        }
                                                        else
                                                        {