WordPress.org

Make WordPress Core

Ticket #23625: 23625.14.diff

File 23625.14.diff, 1.8 KB (added by wonderboymusic, 2 years ago)
  • wp-includes/post-formats.php

    diff --git wp-includes/post-formats.php wp-includes/post-formats.php
    index a6e1049..ec964b6 100644
    function add_chat_detection_format( $name, $newline_regex, $delimiter_regex ) { 
    453453        $_wp_chat_parsers = array( $name => array( $newline_regex, $delimiter_regex ) ) + $_wp_chat_parsers; 
    454454} 
    455455add_chat_detection_format( 'IM', '#^([^:]+):#', '#[:]#' ); 
    456 add_chat_detection_format( 'Skype', '#^(\[.+?\])\s([^:]+):#', '#[:]#' ); 
     456add_chat_detection_format( 'Skype', '#(\[.+?\])\s([^:]+):#', '#[:]#' ); 
    457457 
    458458/** 
    459459 * Deliberately interpret passed content as a chat transcript that is optionally 
    add_chat_detection_format( 'Skype', '#^(\[.+?\])\s([^:]+):#', '#[:]#' ); 
    492492function get_content_chat( &$content, $remove = false ) { 
    493493        global $_wp_chat_parsers; 
    494494 
    495         $trimmed = trim( $content ); 
     495        $trimmed = strip_tags( trim( $content ) ); 
    496496        if ( empty( $trimmed ) ) 
    497497                return array(); 
    498498 
    function get_content_chat( &$content, $remove = false ) { 
    512512        $stanzas = $data = $stanza = array(); 
    513513        $author = $time = ''; 
    514514        $lines = explode( "\n", make_clickable( $trimmed ) ); 
    515  
     515        $found = false; 
    516516 
    517517        foreach ( $lines as $index => $line ) { 
    518518                $line = trim( $line ); 
    519519 
    520                 if ( empty( $line ) ) { 
     520                if ( empty( $line ) && $found ) { 
    521521                        if ( ! empty( $author ) ) { 
    522522                                $stanza[] = array( 
    523523                                        'time'    => $time, 
    function get_content_chat( &$content, $remove = false ) { 
    538538 
    539539                $matches = array(); 
    540540                $matched = preg_match( $newline_regex, $line, $matches ); 
     541                if ( ! $matched ) 
     542                        continue; 
     543 
     544                $found = true; 
    541545                $author_match = empty( $matches[2] ) ? $matches[1] : $matches[2]; 
    542546                // assume username syntax if no whitespace is present 
    543547                $no_ws = $matched && ! preg_match( '#[\r\n\t ]#', $author_match );