)]}'
{
  "commit": "989f6a3800f06b2bd31cfef7c3269a443ad94fac",
  "tree": "9619af8572ace4a7cb6777d7413e0801463950a5",
  "parents": [
    "7dc505b8655b3e48b93a4274dfd26e5856d9c64f"
  ],
  "author": {
    "name": "wouter bolsterlee",
    "email": "wouter@bolsterl.ee",
    "time": "Thu Aug 26 14:49:03 2021"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Thu Aug 26 14:49:03 2021"
  },
  "message": "bpo-45001: Make email date parsing more robust against malformed input (GH-27946)\n\nVarious date parsing utilities in the email module, such as\r\nemail.utils.parsedate(), are supposed to gracefully handle invalid\r\ninput, typically by raising an appropriate exception or by returning\r\nNone.\r\n\r\nThe internal email._parseaddr._parsedate_tz() helper used by some of\r\nthese date parsing routines tries to be robust against malformed input,\r\nbut unfortunately it can still crash ungracefully when a non-empty but\r\nwhitespace-only input is passed. This manifests as an unexpected\r\nIndexError.\r\n\r\nIn practice, this can happen when parsing an email with only a newline\r\ninside a ‘Date:’ header, which unfortunately happens occasionally in the\r\nreal world.\r\n\r\nHere\u0027s a minimal example:\r\n\r\n    $ python\r\n    Python 3.9.6 (default, Jun 30 2021, 10:22:16)\r\n    [GCC 11.1.0] on linux\r\n    Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n    \u003e\u003e\u003e import email.utils\r\n    \u003e\u003e\u003e email.utils.parsedate(\u0027foo\u0027)\r\n    \u003e\u003e\u003e email.utils.parsedate(\u0027 \u0027)\r\n    Traceback (most recent call last):\r\n      File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\n      File \"/usr/lib/python3.9/email/_parseaddr.py\", line 176, in parsedate\r\n        t \u003d parsedate_tz(data)\r\n      File \"/usr/lib/python3.9/email/_parseaddr.py\", line 50, in parsedate_tz\r\n        res \u003d _parsedate_tz(data)\r\n      File \"/usr/lib/python3.9/email/_parseaddr.py\", line 72, in _parsedate_tz\r\n        if data[0].endswith(\u0027,\u0027) or data[0].lower() in _daynames:\r\n    IndexError: list index out of range\r\n\r\nThe fix is rather straight-forward: guard against empty lists, after\r\nsplitting on whitespace, but before accessing the first element.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "4d27f87974b20df20d0d03abe59bdb8c9335ef4c",
      "old_mode": 33188,
      "old_path": "Lib/email/_parseaddr.py",
      "new_id": "977fedf67b1591db4fe2ac532523e4e056bdac3a",
      "new_mode": 33188,
      "new_path": "Lib/email/_parseaddr.py"
    },
    {
      "type": "modify",
      "old_id": "0154bbad1f63f460b237c2e529b887f37bdeabc7",
      "old_mode": 33188,
      "old_path": "Lib/test/test_email/test_email.py",
      "new_id": "4001f716471dc2431c5ed1ba1bbeeb955e9791fe",
      "new_mode": 33188,
      "new_path": "Lib/test/test_email/test_email.py"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "55cc409d0da30fdbc78dd75818b62b4ad8b4991c",
      "new_mode": 33188,
      "new_path": "Misc/NEWS.d/next/Library/2021-08-26-16-25-48.bpo-45001.tn_dKp.rst"
    }
  ]
}
