Make WordPress Core


Ignore:
Timestamp:
05/10/2013 10:54:33 PM (12 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.