Skip to content

Make date string regex more lenient

The current regex, although technically exact according to the ISO8601 standard, gives messages such as this for any file with metadata added without using a zero-padded hour offset:

Could not insert metadata for item "file:///home/jgoguen/Music/Yoshikazu%20Mera,%20Japan%20Philharmonic%20Orchestra%20&%20Shigeo%20Genda/The%20100%20Most%20Essential%20Pieces%20of%20Classical%20Music/Xerxes,%20HWV%2040:%20%22Ombra%20mai%20fu%22%20(Largo).m4a": Not a ISO 8601 date string. Allowed form is [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]

According to tracker extract there's only one date in the file metadata for this music file:

nie:contentCreated "1966-06-11T06:27:46-7:00"

Since conversion of the regex matches is done using atoi there's nothing preventing accepting a single-digit hour offset, so be lenient and allow it.

Unit tests pass:

TZ=UTC ninja test
...
OK:        50
FAIL:       0
SKIP:       0
TIMEOUT:    0

Also rebuilt the Fedora 28 tracker package with this patch, it runs fine and does not complain abouta bad date format.

Merge request reports