@@ -43,27 +43,29 @@ public function parse( $file ) {
4343 $ importline = rtrim ( $ this ->fgets ( $ fp ) );
4444
4545 if ( ! $ wxr_version && preg_match ( '|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>| ' , $ importline , $ version ) ) {
46- $ wxr_version = $ version [1 ];
46+ $ wxr_version = isset ( $ version [1 ] ) ? $ version [ 1 ] : '' ;
4747 }
4848
4949 if ( false !== strpos ( $ importline , '<wp:base_site_url> ' ) ) {
5050 preg_match ( '|<wp:base_site_url>(.*?)</wp:base_site_url>|is ' , $ importline , $ url );
51- $ this ->base_url = $ url [1 ];
51+ $ this ->base_url = isset ( $ url [1 ] ) ? $ url [ 1 ] : '' ;
5252 continue ;
5353 }
5454
5555 if ( false !== strpos ( $ importline , '<wp:base_blog_url> ' ) ) {
5656 preg_match ( '|<wp:base_blog_url>(.*?)</wp:base_blog_url>|is ' , $ importline , $ blog_url );
57- $ this ->base_blog_url = $ blog_url [1 ];
57+ $ this ->base_blog_url = isset ( $ blog_url [1 ] ) ? $ blog_url [ 1 ] : '' ;
5858 continue ;
5959 } elseif ( empty ( $ this ->base_blog_url ) ) {
6060 $ this ->base_blog_url = $ this ->base_url ;
6161 }
6262
6363 if ( false !== strpos ( $ importline , '<wp:author> ' ) ) {
6464 preg_match ( '|<wp:author>(.*?)</wp:author>|is ' , $ importline , $ author );
65- $ a = $ this ->process_author ( $ author [1 ] );
66- $ this ->authors [ $ a ['author_login ' ] ] = $ a ;
65+ if ( isset ( $ author [1 ] ) ) {
66+ $ a = $ this ->process_author ( $ author [1 ] );
67+ $ this ->authors [ $ a ['author_login ' ] ] = $ a ;
68+ }
6769 continue ;
6870 }
6971
@@ -72,7 +74,7 @@ public function parse( $file ) {
7274 $ pos = strpos ( $ importline , "< $ tag> " );
7375 $ pos_closing = strpos ( $ importline , "</ $ tag> " );
7476 if ( preg_match ( '|< ' . $ tag . '>(.*?)</ ' . $ tag . '>|is ' , $ importline , $ matches ) ) {
75- $ this ->{$ handler [0 ]}[] = call_user_func ( $ handler [1 ], $ matches [1 ] );
77+ $ this ->{$ handler [0 ]}[] = call_user_func ( $ handler [1 ], isset ( $ matches [1 ] ) ? $ matches [ 1 ] : '' );
7678
7779 } elseif ( false !== $ pos ) {
7880 // Take note of any content after the opening tag
@@ -115,14 +117,19 @@ public function parse( $file ) {
115117 }
116118
117119 public function get_tag ( $ text , $ tag ) {
120+ if ( null === $ text ) {
121+ return '' ;
122+ }
118123 preg_match ( "|< $ tag.*?>(.*?)</ $ tag>|is " , $ text , $ return );
119124 if ( isset ( $ return [1 ] ) ) {
120125 if ( substr ( $ return [1 ], 0 , 9 ) == '<![CDATA[ ' ) {
121126 if ( strpos ( $ return [1 ], ']]]]><![CDATA[> ' ) !== false ) {
122127 preg_match_all ( '|<!\[CDATA\[(.*?)\]\]>|s ' , $ return [1 ], $ matches );
123128 $ return = '' ;
124- foreach ( $ matches [1 ] as $ match ) {
125- $ return .= $ match ;
129+ if ( isset ( $ matches [1 ] ) ) {
130+ foreach ( $ matches [1 ] as $ match ) {
131+ $ return .= $ match ;
132+ }
126133 }
127134 } else {
128135 $ return = preg_replace ( '|^<!\[CDATA\[(.*)\]\]>$|s ' , '$1 ' , $ return [1 ] );
0 commit comments