Skip to content

OPML Files with ISO 8601 dates cause failures in listparser. #123

@allenhutchison

Description

@allenhutchison

I'm trying to use listparser to parse an OPML file from the OSS podcast manager podgrab. That software creates dates in the OPML in the ISO 8601 format rather than the RFC 822 format that listparser expects.

Here is a minimal test that demonstrates the issue:

#!/usr/bin/env python3

"""
Minimal test case for listparser bug with ISO 8601 dates in OPML files.

This demonstrates the bug with ISO 8601 dates in OPML files and the fix.
"""

import listparser

# Minimal OPML file with ISO 8601 date format
minimal_opml = """<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0">
    <head>
        <title>Test Feed Export</title>
        <dateCreated>2025-04-07T19:52:30.941378073Z</dateCreated>
    </head>
    <body>
        <outline title="Test Feed" xmlUrl="https://example.com/feed" text="Test Feed" type="rss"></outline>
    </body>
</opml>"""

def main():
    # Parse the OPML file
    result = listparser.parse(minimal_opml)
    
    # Check if there was an error
    if result['bozo'] == 1:
        print(f"Error detected: {result['bozo_exception']}")
        print("\nThis error occurs because the OPML parser expects dates in RFC 822 format,")
        print("but the file contains a date in ISO 8601 format (2025-04-07T19:52:30.941378073Z).")
        print("\nFIX: The library has been updated to support both RFC 822 and ISO 8601 date formats.")
    else:
        print("SUCCESS: The OPML file with ISO 8601 date was parsed correctly.")
        print(f"\nParsed date: {result['meta']['created_parsed']}")
        print("\nThe fix adds support for ISO 8601 date formats in addition to RFC 822 formats.")

if __name__ == "__main__":
    main() 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions