WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#3896 closed defect (bug) (fixed)

Wrong indices in match array in parse_w3cdtf

Reported by: mortenf Owned by:
Milestone: 2.1.3 Priority: normal
Severity: critical Version: 2.1.1
Component: General Keywords: has-patch
Focuses: 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 (2)

rss.diff (627 bytes) - added by mortenf 7 years ago.
test.php (553 bytes) - added by jhodgdon 7 years ago.
Test script for parsing dates

Download all attachments as: .zip

Change History (7)

mortenf7 years ago

comment:1 mortenf7 years ago

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

comment:2 markjaquith7 years ago

Additional milestone: 2.0.10

comment:3 jhodgdon7 years ago

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.

jhodgdon7 years ago

Test script for parsing dates

comment:4 ryan7 years ago

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:5 ryan7 years ago

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

Note: See TracTickets for help on using tickets.