diff --git wp-includes/post-formats.php wp-includes/post-formats.php
index a6e1049..977d960 100644
|
|
function add_chat_detection_format( $name, $newline_regex, $delimiter_regex ) { |
453 | 453 | $_wp_chat_parsers = array( $name => array( $newline_regex, $delimiter_regex ) ) + $_wp_chat_parsers; |
454 | 454 | } |
455 | 455 | add_chat_detection_format( 'IM', '#^([^:]+):#', '#[:]#' ); |
456 | | add_chat_detection_format( 'Skype', '#^(\[.+?\])\s([^:]+):#', '#[:]#' ); |
| 456 | add_chat_detection_format( 'Skype', '#(\[.+?\])\s([^:]+):#', '#[:]#' ); |
457 | 457 | |
458 | 458 | /** |
459 | 459 | * Deliberately interpret passed content as a chat transcript that is optionally |
… |
… |
add_chat_detection_format( 'Skype', '#^(\[.+?\])\s([^:]+):#', '#[:]#' ); |
492 | 492 | function get_content_chat( &$content, $remove = false ) { |
493 | 493 | global $_wp_chat_parsers; |
494 | 494 | |
495 | | $trimmed = trim( $content ); |
| 495 | $trimmed = strip_tags( trim( $content ) ); |
496 | 496 | if ( empty( $trimmed ) ) |
497 | 497 | return array(); |
498 | 498 | |
… |
… |
function get_content_chat( &$content, $remove = false ) { |
512 | 512 | $stanzas = $data = $stanza = array(); |
513 | 513 | $author = $time = ''; |
514 | 514 | $lines = explode( "\n", make_clickable( $trimmed ) ); |
515 | | |
| 515 | $found = false; |
| 516 | $found_index = 0; |
516 | 517 | |
517 | 518 | foreach ( $lines as $index => $line ) { |
| 519 | if ( ! $found ) |
| 520 | $found_index = $index; |
| 521 | |
518 | 522 | $line = trim( $line ); |
519 | 523 | |
520 | | if ( empty( $line ) ) { |
| 524 | if ( empty( $line ) && $found ) { |
521 | 525 | if ( ! empty( $author ) ) { |
522 | 526 | $stanza[] = array( |
523 | 527 | 'time' => $time, |
… |
… |
function get_content_chat( &$content, $remove = false ) { |
527 | 531 | } |
528 | 532 | |
529 | 533 | $stanzas[] = $stanza; |
530 | | $last_index = $index; |
| 534 | |
531 | 535 | $stanza = $data = array(); |
532 | 536 | $author = $time = ''; |
533 | 537 | if ( ! empty( $lines[$index + 1] ) && ! preg_match( $delimiter_regex, $lines[$index + 1] ) ) |
… |
… |
function get_content_chat( &$content, $remove = false ) { |
538 | 542 | |
539 | 543 | $matches = array(); |
540 | 544 | $matched = preg_match( $newline_regex, $line, $matches ); |
| 545 | if ( ! $matched ) |
| 546 | continue; |
| 547 | |
| 548 | $found = true; |
| 549 | $last_index = $index; |
541 | 550 | $author_match = empty( $matches[2] ) ? $matches[1] : $matches[2]; |
542 | 551 | // assume username syntax if no whitespace is present |
543 | 552 | $no_ws = $matched && ! preg_match( '#[\r\n\t ]#', $author_match ); |
… |
… |
function get_content_chat( &$content, $remove = false ) { |
572 | 581 | if ( ! empty( $stanza ) ) |
573 | 582 | $stanzas[] = $stanza; |
574 | 583 | |
575 | | if ( $remove ) |
576 | | $content = trim( join( "\n", array_slice( $lines, $last_index ) ) ); |
| 584 | if ( $remove ) { |
| 585 | if ( 0 === $found_index ) { |
| 586 | $removed = array_slice( $lines, $last_index ); |
| 587 | } else { |
| 588 | $before = array_slice( $lines, 0, $found_index ); |
| 589 | $after = array_slice( $lines, $last_index + 1 ); |
| 590 | $removed = array_filter( array_merge( $before, $after ) ); |
| 591 | } |
| 592 | $content = trim( join( "\n", $removed ) ); |
| 593 | } |
577 | 594 | |
578 | 595 | return $stanzas; |
579 | 596 | } |