Ticket #11574: 11574-improved.diff

File 11574-improved.diff, 886 bytes (added by westi, 3 years ago)

Better patch which merges the two regexs and preserves the old non-greed behaviour

Line 
1### Eclipse Workspace Patch 1.0
2#P wordpress-tests
3Index: wordpress/wp-admin/import/wordpress.php
4===================================================================
5--- wordpress/wp-admin/import/wordpress.php     (revision 12506)
6+++ wordpress/wp-admin/import/wordpress.php     (working copy)
7@@ -59,10 +59,11 @@
8 
9        function get_tag( $string, $tag ) {
10                global $wpdb;
11-               preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
12-               if ( isset($return[1]) ) {
13-                       $return = preg_replace('|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1]);
14-                       $return = $wpdb->escape( trim( $return ) );
15+               preg_match("@(<$tag.*?><!\[CDATA\[(.*?)\]\]></$tag>|<$tag.*?>(.*?)</$tag>)@is", $string, $return);
16+               if ( !empty($return[2]) ) {
17+                       $return = $wpdb->escape( trim( $return[2] ) );
18+               } else if ( !empty($return[3]) ) {
19+                       $return = $wpdb->escape( trim( $return[3] ) );
20                } else {
21                        $return = '';
22                }