Skip to content
This repository has been 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

Open
Ryokuhi opened this issue Oct 4, 2021 · 0 comments · May be fixed by #227
Open

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

Ryokuhi opened this issue Oct 4, 2021 · 0 comments · May be fixed by #227
Labels
Type: Bug There is a bug in the plugin.

Comments

@Ryokuhi
Copy link

Ryokuhi commented Oct 4, 2021

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).

@Ryokuhi Ryokuhi added the Type: Bug There is a bug in the plugin. label Oct 4, 2021
Ryokuhi referenced this issue in Ryokuhi/theme-sniffer Oct 4, 2021
Line breaks between headers are not forbidden, but the readme.txt parser
failed if there was an empty line between them.

The parser code is intended to allow line breaks between headers, but a
small bug prevented this.

Resolves: #226
@Ryokuhi Ryokuhi linked a pull request Oct 4, 2021 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Bug There is a bug in the plugin.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant