]> granicus.if.org Git - php/commitdiff
- Fixed bug #44703 (htmlspecialchars() does not detect bad character set
authorDerick Rethans <derick@php.net>
Wed, 16 Apr 2008 17:21:46 +0000 (17:21 +0000)
committerDerick Rethans <derick@php.net>
Wed, 16 Apr 2008 17:21:46 +0000 (17:21 +0000)
  argument).

NEWS
ext/date/php_date.c
ext/date/tests/bug44742.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 7d0d31e332a8c22887fa78ada826a6aaa02b4e03..dadd9ddd68f64202cd764a237bc579bb01257622 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,9 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Apr 2008, PHP 5.2.6
-- Fixed bug #44703 (htmlspecialchars() does not detect bad character set argument)
-  (Andy Wharmby)
+- Fixed bug #44703 (htmlspecialchars() does not detect bad character set
+  argument). (Andy Wharmby)
+- Fixed bug #44742 (timezone_offset_get() causes segmentation faults). (Derick)
 
 10 Apr 2008, PHP 5.2.6RC5
 - Fixed incorrect heredoc handling when label is used within the block.
@@ -29,6 +30,9 @@ PHP                                                                        NEWS
   (Ilia)
 - Fixed bug #44557 (Crash in imap_setacl when supplied integer as username)
   (Thomas Jarosch)
+- Fixed a bug in formatting timestamps when DST is active in the default
+  timezone (Derick)
+
 
 27 Mar 2008, PHP 5.2.6RC3
 - Properly address incomplete multibyte chars inside escapeshellcmd() (Ilia,
index f1a72e1f986d9ff402840ec2a0c7aea55eaa26d2..a31983185967cbff92e9f3869f6d07a0a10eb835 100644 (file)
@@ -2271,9 +2271,19 @@ PHP_FUNCTION(timezone_offset_get)
        dateobj = (php_date_obj *) zend_object_store_get_object(dateobject TSRMLS_CC);
        DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
 
-       offset = timelib_get_time_zone_info(dateobj->time->sse, tzobj->tzi.tz);
-       RETVAL_LONG(offset->offset);
-       timelib_time_offset_dtor(offset);
+       switch (tzobj->type) {
+               case TIMELIB_ZONETYPE_ID:
+                       offset = timelib_get_time_zone_info(dateobj->time->sse, tzobj->tzi.tz);
+                       RETVAL_LONG(offset->offset);
+                       timelib_time_offset_dtor(offset);
+                       break;
+               case TIMELIB_ZONETYPE_OFFSET:
+                       RETURN_LONG(tzobj->tzi.utc_offset * -60);
+                       break;
+               case TIMELIB_ZONETYPE_ABBR:
+                       RETURN_LONG((tzobj->tzi.z.utc_offset - (tzobj->tzi.z.dst*60)) * -60);
+                       break;
+       }
 }
 /* }}} */
 
diff --git a/ext/date/tests/bug44742.phpt b/ext/date/tests/bug44742.phpt
new file mode 100644 (file)
index 0000000..e6df1ef
--- /dev/null
@@ -0,0 +1,35 @@
+--TEST--
+Bug #44742 (timezone_offset_get() causes segmentation faults)
+--FILE--
+<?php
+$dates = array(
+       "2008-04-11 00:00:00+0000",
+       "2008-04-11 00:00:00+0200",
+       "2008-04-11 00:00:00+0330",
+       "2008-04-11 00:00:00-0500",
+       "2008-04-11 00:00:00-1130",
+       "2008-04-11 00:00:00 CEST",
+       "2008-04-11 00:00:00 CET",
+       "2008-04-11 00:00:00 UTC",
+       "2008-04-11 00:00:00 America/New_York",
+       "2008-04-11 00:00:00 Europe/Oslo",
+       "2008-04-11 00:00:00 Asia/Singapore",
+);
+foreach ($dates as $date)
+{
+       $date = date_create($date);
+       var_dump(timezone_offset_get(date_timezone_get($date), $date));
+}
+?>
+--EXPECT--
+int(0)
+int(7200)
+int(12600)
+int(-18000)
+int(-41400)
+int(7200)
+int(3600)
+int(0)
+int(-14400)
+int(7200)
+int(28800)