Skip to content

IndexError in DateTimeParser.parse #1191

@gabe-sherman

Description

@gabe-sherman

The below code triggers a list index out of range error when provided a malformed input. This occurs in parse at line 335 in arrow/parser.py.
It seems that when the fmt string is malformed this can lead to a matching error in the regex parsing later in the function.

from arrow.parser import DateTimeParser
import sys

buf = open(sys.argv[1], "rb").read().decode("utf-8")
parser = DateTimeParser()
parser.parse("foo", buf)

Version

1.3.0

POC File

https://github.com/FuturesLab/POC/blob/main/arrow-py/poc-01

How to trigger

python filename.py poc-01

Trace Report

Traceback (most recent call last):
  File "rep.py", line 6, in <module>
    parser.parse("foo", buf)
  File "anon/lib/python3.8/site-packages/arrow/parser.py", line 331, in parse
    value = match.group(token)
IndexError: no such group

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions