OSDN Git Service

BugTrack/2187 Fix doubled HTML-escaped text in bugtrack_list summary
[pukiwiki/pukiwiki.git] / plugin / showrss.inc.php
index 2570930..bfa799b 100644 (file)
@@ -1,9 +1,8 @@
 <?php
 // PukiWiki - Yet another WikiWikiWeb clone
-// $Id: showrss.inc.php,v 1.20 2006/05/05 04:25:28 henoheno Exp $
-//  Id:showrss.inc.php,v 1.40 2003/03/18 11:52:58 hiro Exp
-// Copyright (C):
-//     2002-2006 PukiWiki Developers Team
+// showrss.inc.php
+// Copyright:
+//     2002-2016 PukiWiki Development Team
 //     2002      PANDA <panda@arino.jp>
 //     (Original)hiro_do3ob@yahoo.co.jp
 // License: GPL, same as PukiWiki
@@ -53,11 +52,11 @@ function plugin_showrss_convert()
 
        $class = ($template == '' || $template == 'default') ? 'ShowRSS_html' : 'ShowRSS_html_' . $template;
        if (! is_numeric($cachehour))
-               return '#showrss: Cache-lifetime seems not numeric: ' . htmlspecialchars($cachehour) . '<br />' . "\n";
+               return '#showrss: Cache-lifetime seems not numeric: ' . htmlsc($cachehour) . '<br />' . "\n";
        if (! class_exists($class))
-               return '#showrss: Template not found: ' . htmlspecialchars($template) . '<br />' . "\n";
+               return '#showrss: Template not found: ' . htmlsc($template) . '<br />' . "\n";
        if (! is_url($uri))
-               return '#showrss: Seems not URI: ' . htmlspecialchars($uri) . '<br />' . "\n";
+               return '#showrss: Seems not URI: ' . htmlsc($uri) . '<br />' . "\n";
 
        list($rss, $time) = plugin_showrss_get_rss($uri, $cachehour);
        if ($rss === FALSE) return '#showrss: Failed fetching RSS from the server<br />' . "\n";
@@ -80,6 +79,10 @@ class ShowRSS_html
 
        function ShowRSS_html($rss)
        {
+               $this->__construct($rss);
+       }
+       function __construct($rss)
+       {
                foreach ($rss as $date=>$items) {
                        foreach ($items as $item) {
                                $link  = $item['LINK'];
@@ -167,7 +170,7 @@ function plugin_showrss_get_rss($target, $cachehour)
 
        if ($time === NULL) {
                // Newly get RSS
-               $data = http_request($target);
+               $data = pkwk_http_request($target);
                if ($data['rc'] !== 200)
                        return array(FALSE, 0);
 
@@ -219,7 +222,7 @@ class ShowRSS_XML
 
                // Detect encoding
                $matches = array();
-               if(preg_match('/<?xml [^>]*\bencoding="([a-z0-9-_]+)"/i', $buf, $matches)) {
+               if(preg_match('/<\?xml [^>]*\bencoding="([a-z0-9-_]+)"/i', $buf, $matches)) {
                        $this->encoding = $matches[1];
                } else {
                        $this->encoding = mb_detect_encoding($buf);
@@ -247,10 +250,10 @@ class ShowRSS_XML
 
        function escape($str)
        {
-               // Unescape already-escaped chars (&lt;, &gt;, &amp;, ...) in RSS body before htmlspecialchars()
+               // Unescape already-escaped chars (&lt;, &gt;, &amp;, ...) in RSS body before htmlsc()
                $str = strtr($str, array_flip(get_html_translation_table(ENT_COMPAT)));
                // Escape
-               $str = htmlspecialchars($str);
+               $str = htmlsc($str);
                // Encoding conversion
                $str = mb_convert_encoding($str, SOURCE_ENCODING, $this->encoding);
                return trim($str);
@@ -323,4 +326,3 @@ function plugin_showrss_get_timestamp($str)
                return ($time == -1) ? UTIME : $time - LOCALZONE;
        }
 }
-?>