Skip to content

parseMetadata IndexError on blank line inside metadata block #1233

Description

@chirag127

Problem

parseMetadata() in tests/database-tests.py crashes with IndexError: string index out of range when a metadata block contains a blank line.

Steps

  1. Create a lyrics file with a blank line inside the metadata section (after the ___ separator).
  2. Run cd tests && make (or python3 database-tests.py).

Expected

Test suite parses metadata cleanly or reports a warning.

Actual

IndexError: string index out of range

at tests/database-tests.py:62:

if line[0] == ' ':

line can be empty after line.rstrip() on line 61; line[0] then raises.

Fix

Guard with if line and line[0] == ' ': or continue on empty lines.

Env

Python 3.x, any OS. File unchanged since introduction.

Thanks for maintaining Lyrics/lyrics-database!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions