[wp-trac] [WordPress Trac] #29119: Wrong regex $yt_pattern to manage YouTube videos in wp_video_shortcode
WordPress Trac
noreply at wordpress.org
Tue Aug 5 15:28:11 UTC 2014
#29119: Wrong regex $yt_pattern to manage YouTube videos in wp_video_shortcode
--------------------------+-----------------------------
Reporter: Fab1en | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 3.9.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
`wp_video_shortcode` uses the following regular expression to find YouTube
videos and make them play correctly inside MediaElementJS player :
{{{
$yt_pattern = '#^https?://(:?www\.)?(:?youtube\.com/watch|youtu\.be/)#';
}}}
I think the `:?` in front of `www` and `youtube` are here to make the
parenthesis non capturing. In this case this is incorrect : the right
signs to use are `?:`. The current formulation (`:?`) will optionally
match a `:`.
Note that this is not really a bug, because there are no consequences :
matches are not used afterward, and `:` will never appear in a URL at this
place. But this is confusing and might cause a bug later.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29119>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list