Ticket #3896 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Wrong indices in match array in parse_w3cdtf

Reported by: mortenf Assigned to: anonymous
Priority: normal Milestone: 2.1.3
Component: General Version: 2.1.1
Severity: critical Keywords: has-patch
Cc:

Description

In rss.php, in the function parse_w3cdtf, the date/time string to parse is matched against a regular expression, which captures parts using parantheses. The resulting array, $match, is then indexed to obtain each part, but the indices used are wrong in two cases.

Running on some versions of PHP, this leads to a warning when calling the function gmmktime:

Warning:  gmmktime() expects parameter 3 to be long, string given in ...

The warning also makes the function return 0, leading to incorrect results.

Attachments

rss.diff (0.6 kB) - added by mortenf on 03/01/07 22:38:58.
test.php (0.5 kB) - added by jhodgdon on 03/07/07 15:50:06.
Test script for parsing dates

Change History

03/01/07 22:38:58 changed by mortenf

  • attachment rss.diff added.

03/01/07 22:42:20 changed by mortenf

This issue is also present in the 2.0.x branch.

03/02/07 07:51:11 changed by markjaquith

Additional milestone: 2.0.10

03/07/07 15:49:31 changed by jhodgdon

I believe this patch is good.

I just did a little test program to parse a date string (which I will attach directly), and found that array item 7 has the seconds, and number 11 has the "Z" if present. The current rss.php (as of SVN revision [4718] of rss.php) definitely has the indices wrong (6 and 10 respectively), and the patch fixes it.

So I recommend installing this patch.

03/07/07 15:50:06 changed by jhodgdon

  • attachment test.php added.

Test script for parsing dates

03/07/07 17:04:04 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [4997]) Fix parse_w3cdtf. Props mortenf. fixes #3896

03/07/07 17:04:40 changed by ryan

(In [4998]) Fix parse_w3cdtf. Props mortenf. fixes #3896