This repository was archived by the owner on Sep 27, 2023. It is now read-only.
forked from grappler/ns-theme-check
-
Notifications
You must be signed in to change notification settings - Fork 4
[Bug] readme.txt parser fails if there are empty lines between headers #226
Copy link
Copy link
Open
Labels
Type: BugThere is a bug in the plugin.There is a bug in the plugin.
Description
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
- 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.
- Run the Theme Sniffer: you'll get the two following warnings (since the parser cannot parse the License header, the
licenseproperty is empty).- No matching license critera could be determined from: !
- Unable to determine License URI with an invalid License supplied in readme.txt!
- Remove the empty line between headers in the
readme.txtfile. - 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.
theme-sniffer/src/sniffs/readme/class-parser.php
Lines 233 to 238 in 1d6c852
| // 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).Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type: BugThere is a bug in the plugin.There is a bug in the plugin.