• R/O
  • HTTP
  • SSH
  • HTTPS

pukiwiki: Commit


Commit MetaInfo

Revision6b278364164af06f7cee52bfe5f97a8a5f7544c9 (tree)
Time2017-02-17 00:09:23
Authorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack/2414 strtotime return false on parsing failure in PHP5.1+

http://php.net/manual/en/function.strtotime.php
Returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0,
this function would return -1 on failure.

Change Summary

Incremental Difference

--- a/plugin/calendar_viewer.inc.php
+++ b/plugin/calendar_viewer.inc.php
@@ -1,7 +1,7 @@
11 <?php
22 // PukiWiki - Yet another WikiWikiWeb clone
3-// $Id: calendar_viewer.inc.php,v 1.37 2011/01/25 15:01:01 henoheno Exp $
4-// Copyright (C) 2002-2005, 2007 PukiWiki Developers Team
3+// calendar_viewer.inc.php
4+// Copyright 2002-2017 PukiWiki Development Team
55 // License: GPL v2 or (at your option) any later version
66 //
77 // Calendar viewer plugin - List pages that calendar/calnedar2 plugin created
@@ -177,7 +177,7 @@ function plugin_calendar_viewer_convert()
177177
178178 if (PLUGIN_CALENDAR_VIEWER_DATE_FORMAT !== FALSE) {
179179 $time = strtotime(basename($page)); // $date_sep must be assumed '-' or ''!
180- if ($time == -1) {
180+ if ($time === FALSE || $time === -1) {
181181 $s_page = htmlsc($page); // Failed. Why?
182182 } else {
183183 $week = $weeklabels[date('w', $time)];
@@ -330,4 +330,3 @@ function plugin_calendar_viewer_isValidDate($aStr, $aSepList = '-/ .')
330330 return FALSE;
331331 }
332332 }
333-
--- a/plugin/new.inc.php
+++ b/plugin/new.inc.php
@@ -1,6 +1,8 @@
11 <?php
22 // PukiWiki - Yet another WikiWikiWeb clone.
3-// $Id: new.inc.php,v 1.10 2011/01/25 15:01:01 henoheno Exp $
3+// new.inc.php
4+// Copyright 2003-2017 PukiWiki Development Team
5+// License: GPL v2 or (at your option) any later version
46 //
57 // New! plugin
68 //
--- a/plugin/showrss.inc.php
+++ b/plugin/showrss.inc.php
@@ -2,7 +2,7 @@
22 // PukiWiki - Yet another WikiWikiWeb clone
33 // showrss.inc.php
44 // Copyright:
5-// 2002-2016 PukiWiki Development Team
5+// 2002-2017 PukiWiki Development Team
66 // 2002 PANDA <panda@arino.jp>
77 // (Original)hiro_do3ob@yahoo.co.jp
88 // License: GPL, same as PukiWiki
@@ -282,14 +282,17 @@ class ShowRSS_XML
282282
283283 } else if (isset($item['PUBDATE'])) {
284284 $time = plugin_showrss_get_timestamp($item['PUBDATE']);
285-
286- } else if (isset($item['DESCRIPTION']) &&
287- ($description = trim($item['DESCRIPTION'])) != '' &&
288- ($time = strtotime($description)) != -1) {
289- $time -= LOCALZONE;
290-
291285 } else {
292- $time = time() - LOCALZONE;
286+ $time_from_desc = FALSE;
287+ if (isset($item['DESCRIPTION']) &&
288+ (($description = trim($item['DESCRIPTION'])) != '')) {
289+ $time_from_desc = strtotime($description);
290+ }
291+ if ($time_from_desc !== FALSE && $time_from_desc !== -1) {
292+ $time = $time_from_desc - LOCALZONE;
293+ } else {
294+ $time = time() - LOCALZONE;
295+ }
293296 }
294297 $item['_TIMESTAMP'] = $time;
295298 $date = get_date('Y-m-d', $item['_TIMESTAMP']);
@@ -314,7 +317,7 @@ function plugin_showrss_get_timestamp($str)
314317 $matches = array();
315318 if (preg_match('/(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(([+-])(\d{2}):(\d{2}))?/', $str, $matches)) {
316319 $time = strtotime($matches[1] . ' ' . $matches[2]);
317- if ($time == -1) {
320+ if ($time === FALSE || $time === -1) {
318321 $time = UTIME;
319322 } else if ($matches[3]) {
320323 $diff = ($matches[5] * 60 + $matches[6]) * 60;
@@ -323,6 +326,6 @@ function plugin_showrss_get_timestamp($str)
323326 return $time;
324327 } else {
325328 $time = strtotime($str);
326- return ($time == -1) ? UTIME : $time - LOCALZONE;
329+ return ($time === FALSE || $time === -1) ? UTIME : $time - LOCALZONE;
327330 }
328331 }
Show on old repository browser