Ticket #3896 (closed defect (bug): fixed)

Opened 5 years ago

Last modified 5 years ago

Wrong indices in match array in parse_w3cdtf

Reported by: mortenf Owned by: 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 Download (627 bytes) - added by mortenf 5 years ago.
test.php Download (553 bytes) - added by jhodgdon 5 years ago.
Test script for parsing dates

Change History

mortenf5 years ago

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

Additional milestone: 2.0.10

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.

Test script for parsing dates

comment:4   ryan5 years ago

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

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

comment:5   ryan5 years ago

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

Note: See TracTickets for help on using tickets.