Changeset 11908
- Timestamp:
- 06/09/2022 01:47:36 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php
r10573 r11908 238 238 $headers = array(); 239 239 240 $line = $this->get_first_nonwhitespace( $contents ); 240 $line = $this->get_first_nonwhitespace( $contents ); 241 $last_line_was_blank = false; 241 242 do { 242 243 $value = null; 243 if ( false === strpos( $line, ':' ) ) { 244 245 // Some plugins have line-breaks within the headers. 244 // If it doesn't look like a header value, maybe break to the next section. 245 if ( ! str_contains( $line, ':' ) || str_starts_with( $line, '#' ) || str_starts_with( $line, '=' ) ) { 246 246 if ( empty( $line ) ) { 247 // Some plugins have line-breaks within the headers... 248 $last_line_was_blank = true; 249 continue; 250 } else { 251 // We've hit a line that is not blank, but also doesn't look like a header, assume the Short Description and end Header parsing. 247 252 break; 248 } else {249 continue;250 253 } 251 254 } … … 254 257 list( $key, $value ) = $bits; 255 258 $key = strtolower( trim( $key, " \t*-\r\n" ) ); 259 256 260 if ( isset( $this->valid_headers[ $key ] ) ) { 257 261 $headers[ $this->valid_headers[ $key ] ] = trim( $value ); 258 } 262 } elseif ( $last_line_was_blank ) { 263 // If we skipped over a blank line, and then ended up with an unexpected header, assume we parsed too far and ended up in the Short Description. 264 // This final line will be added back into the stack after the loop for further parsing. 265 break; 266 } 267 268 $last_line_was_blank = false; 259 269 } while ( ( $line = array_shift( $contents ) ) !== null ); 260 270 array_unshift( $contents, $line );
Note: See TracChangeset
for help on using the changeset viewer.