Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

[Bug] readme.txt parser fails if there are empty lines between headers #226

@Ryokuhi

Description

@Ryokuhi

Describe the bug
In case there is an empty line between headers in the readme.txt file, the parser parses correctly only headers before the empty line: other headers are incorrectly parsed as short description and the short description is not parsed at all.

To Reproduce

  1. Edit the readme.txt file of a theme by adding an empty line between headers. An easy way to catch the bug is to add the empty line before the License header.
  2. Run the Theme Sniffer: you'll get the two following warnings (since the parser cannot parse the License header, the license property is empty).
    • No matching license critera could be determined from: !
    • Unable to determine License URI with an invalid License supplied in readme.txt!
  3. Remove the empty line between headers in the readme.txt file.
  4. Run the Theme Sniffer again: the warnings disappear.

Expected behavior
I'm not aware of guidelines preventing developers from adding line breaks between headers.
As such, I would expect that adding one or more empty lines between headers doesn't cause parsing errors.

Environment

  • OS: Windows
  • Browser: both Chrome and Firefox
  • Version: both 1.1.2 and development
  • PHP Version: 7.4
  • WP Version: development

Additional context
The following snippet shows that the parser has a few lines of code intended to allow line breaks between headers.

// Some plugins have line-breaks within the headers.
if ( empty( $line ) ) {
break;
} else {
continue;
}

The cause of this issue is that the break and continue controls are switched: header parsing should continue if the line is empty and it should break if the line is not empty, but it is not a header either (i.e. if it doesn't contain a colon).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugThere is a bug in the plugin.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions