Make WordPress Core

Changeset 63331


Ignore:
Timestamp:
08/21/2026 01:25:59 PM (3 weeks ago)
Author:
afercia
Message:

General: Make get_tag_regex() match tags non-greedily.

Fixes a bug where get_tag_regex() may match multiple tags of the same type in the content.
Also, adds tests.

Developed in https://github.com/WordPress/wordpress-develop/pull/13037

Props pbearne, kopepasah, gunjanjaswal, debarghyabanerjee, mukesh27, desrosj, ocean90, nacin, chriscct7, r1k0, afercia.
Fixes 26674.
Fixes 59791.

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r63320 r63331  
    77017701                return '';
    77027702        }
    7703         return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) );
     7703        return sprintf( '<%1$s[^<]*?(?:>[\s\S]*?<\/%1$s>|\s*\/>)', tag_escape( $tag ) );
    77047704}
    77057705
Note: See TracChangeset for help on using the changeset viewer.