Ticket #24159: 24159.diff
File 24159.diff, 2.5 KB (added by , 12 years ago) |
---|
-
post-formats.php
556 556 $found_index = 0; 557 557 558 558 foreach ( $lines as $index => $line ) { 559 if ( ! $found ) 560 $found_index = $index; 561 559 $data = array(); 562 560 $line = trim( $line ); 563 564 if ( empty( $line ) && $found ) { 565 if ( ! empty( $author ) ) { 566 $stanza[] = array( 567 'time' => $time, 568 'author' => $author, 569 'message' => join( ' ', $data ) 570 ); 571 } 572 573 $stanzas[] = $stanza; 574 575 $stanza = $data = array(); 576 $author = $time = ''; 577 if ( ! empty( $lines[$index + 1] ) && ! preg_match( $delimiter_regex, $lines[$index + 1] ) ) 578 break; 579 else 580 continue; 581 } 582 561 if ( empty( $line ) ) 562 continue; 583 563 $matched = preg_match( $newline_regex, $line, $matches ); 584 564 if ( ! $matched ) 585 565 continue; 586 587 $found = true; 588 $last_index = $index; 589 $author_match = empty( $matches[2] ) ? $matches[1] : $matches[2]; 590 // assume username syntax if no whitespace is present 591 $no_ws = $matched && ! preg_match( '#[\r\n\t ]#', $author_match ); 592 // allow script-like stanzas 593 $has_ws = $matched && preg_match( '#[\r\n\t ]#', $author_match ) && empty( $lines[$index + 1] ) && empty( $lines[$index - 1] ); 594 if ( $matched && ( ! empty( $matches[2] ) || ( $no_ws || $has_ws ) ) ) { 595 if ( ! empty( $author ) ) { 596 $stanza[] = array( 597 'time' => $time, 598 'author' => $author, 599 'message' => join( ' ', $data ) 600 ); 601 $data = array(); 602 } 603 604 $time = empty( $matches[2] ) ? '' : $matches[1]; 605 $author = $author_match; 606 $data[] = trim( str_replace( $matches[0], '', $line ) ); 607 } elseif ( preg_match( '#\S#', $line ) ) { 608 $data[] = $line; 566 if ( ! empty( $matches[2] ) ) { // Time is present 567 $time = $matches[1]; 568 $author = $matches[2]; 569 } else { 570 $time = ''; 571 $author = $matches[1]; 609 572 } 610 } 611 612 if ( ! empty( $author ) ) { 573 $data[] = trim( str_replace( $matches[0], '', $line ) ); 574 $i = $index; 575 do { 576 $i++; 577 $data[] = $lines[$i]; 578 } while ( preg_match( $newline_regex, $lines[$i], $matches ) ); 613 579 $stanza[] = array( 614 'time' 580 'time' => $time, 615 581 'author' => $author, 616 'message' => trim( join( ' ', $data ) ) 617 ); 582 'message' => trim( join( ' ', $data ) ) ); 618 583 } 619 584 620 585 if ( ! empty( $stanza ) ) … … 1010 975 $data['post_title'] = _post_formats_generate_title( $data['post_content'], $post_format ); 1011 976 1012 977 return $data; 1013 } 1014 Pas de retour chariot à la fin du fichier 978 }