Make WordPress Core

Changeset 24241


Ignore:
Timestamp:
05/10/2013 10:54:33 PM (11 years ago)
Author:
markjaquith
Message:

Improve regular expressions by using a backreference to match right quote of quote pair when matching attributes.

props kovshenin. see #24225.

Location:
trunk/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r24229 r24241  
    32073207    global $_links_add_target;
    32083208    $tag = $m[1];
    3209     $link = preg_replace('|(target=[\'"](.*?)[\'"])|i', '', $m[2]);
     3209    $link = preg_replace('|(target=([\'"])(.*?)\2)|i', '', $m[2]);
    32103210    return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">';
    32113211}
  • trunk/wp-includes/media.php

    r24240 r24241  
    19301930
    19311931    foreach ( $items as $item ) {
    1932         preg_match_all( '#src=[\'"](.+?)[\'"]#is', $item, $src, PREG_SET_ORDER );
     1932        preg_match_all( '#src=([\'"])(.+?)\1#is', $item, $src, PREG_SET_ORDER );
    19331933        if ( ! empty( $src ) ) {
    19341934            $srcs = array();
    19351935            foreach ( $src as $s )
    1936                 $srcs[] = $s[1];
     1936                $srcs[] = $s[2];
    19371937
    19381938            $data[] = array_values( array_unique( $srcs ) );
     
    22552255
    22562256    foreach ( $tags as $tag ) {
    2257         preg_match( '#src=[\'"](.+?)[\'"]#is', $tag, $src );
    2258         if ( ! empty( $src[1] ) ) {
    2259             $srcs[] = $src[1];
     2257        preg_match( '#src=([\'"])(.+?)\1#is', $tag, $src );
     2258        if ( ! empty( $src[2] ) ) {
     2259            $srcs[] = $src[2];
    22602260            if ( $limit > 0 && count( $srcs ) >= $limit )
    22612261                break;
     
    23112311                    $galleries[] = $gallery;
    23122312                } else {
    2313                     preg_match_all( '#src=[\'"](.+?)[\'"]#is', $gallery, $src, PREG_SET_ORDER );
     2313                    preg_match_all( '#src=([\'"])(.+?)\1#is', $gallery, $src, PREG_SET_ORDER );
    23142314                    if ( ! empty( $src ) ) {
    23152315                        foreach ( $src as $s )
    2316                             $srcs[] = $s[1];
     2316                            $srcs[] = $s[2];
    23172317                    }
    23182318
  • trunk/wp-includes/post-formats.php

    r24233 r24241  
    792792        return $trimmed;
    793793    // the content is HTML so we grab the first href
    794     } elseif ( preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', $content, $matches ) ) {
    795         return esc_url_raw( $matches[1] );
     794    } elseif ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) {
     795        return esc_url_raw( $matches[2] );
    796796    }
    797797
Note: See TracChangeset for help on using the changeset viewer.