WordPress.org

Plugin Directory

Ticket #1231: livejournal-importer.patch

File livejournal-importer.patch, 1.5 KB (added by sfllaw, 3 years ago)

Patch to fix some regular expressions in livejournal-importer

  • livejournal-importer.php

    diff -pruN livejournal-importer.orig/livejournal-importer.php livejournal-importer/livejournal-importer.php
    old new class LJ_API_Import extends WP_Importer 
    374374                $post_content = str_replace( '<br>', '<br />', $post_content ); 
    375375                $post_content = str_replace( '<hr>', '<hr />', $post_content ); 
    376376                // lj-cut ==>  <!--more--> 
    377                 $post_content = preg_replace( '|<lj-cut text="([^"]*)">|is', '<!--more $1-->', $post_content ); 
     377                $post_content = preg_replace( '|<\s*lj-cut\s+text="([^"]*)"\s*>|is', '<!--more $1-->', $post_content ); 
    378378                $post_content = str_replace( array( '<lj-cut>', '</lj-cut>' ), array( '<!--more-->', '' ), $post_content ); 
    379379                $first = strpos( $post_content, '<!--more' ); 
    380380                $post_content = substr( $post_content, 0, $first + 1 ) . preg_replace( '|<!--more(.*)?-->|sUi', '', substr( $post_content, $first + 1 ) ); 
    class LJ_API_Import extends WP_Importer 
    415415 
    416416        // Convert lj-user tags to links to that user 
    417417        function translate_lj_user( $str ) { 
    418                 return preg_replace( '|<lj\s+user\s*=\s*["\']([\w-]+)["\']>|', '<a href="http://$1.livejournal.com/" class="lj-user">$1</a>', $str ); 
     418                return preg_replace( '|<\s*lj\s+user\s*=\s*["\']([\w-]+)["\']\s*/?\s*>|', '<a href="http://$1.livejournal.com/" class="lj-user">$1</a>', $str ); 
    419419        } 
    420420 
    421421        function insert_postmeta( $post_id, $post ) {