Skip to content

Commit

Permalink
Improve the matching of the youtube shortcode reversal again.
Browse files Browse the repository at this point in the history
Merges r184358-wpcom

In D17568-code and D17868-code we improved this code.
Those changes accidentally got reversed in D18511-code
I was reviewing #10224 which would merge the original
changes into Jetpack and noted the 's' modifier.
Unfortunately we can't include that here because it means on long but malformed post content we go into an
infinite loop because of the .*? in the RegEx.
This means we can't match objects/mangled objects which have a newline within them but we can match more
that we were

Diff: D21652-code
  • Loading branch information
westi authored and jeherve committed Dec 3, 2018
1 parent eb9b2cb commit e4c966d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/shortcodes/youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function youtube_embed_to_short_code( $content ) {
}

// older codes
$regexp = '!<object([^>]+?)>.*?<param\s+name=[\'"]movie[\'"]\s+value=[\'"](https?:)?//www.youtube.com/v/([^\'"]+)[\'"][^>]*?>.*?</object>!is';
$regexp = '!<object(.*?)>.*?<param\s+name=[\'"]movie[\'"]\s+value=[\'"](https?:)?//www.youtube.com/v/([^\'"]+)[\'"].*?>.*?</object>!i';
$regexp_ent = htmlspecialchars( $regexp, ENT_NOQUOTES );
$old_regexp = '!<embed(?:\s+\w+="[^"]*")*\s+src="https?(?:\:|&#0*58;)//www\.youtube\.com/v/([^"]+)"(?:\s+\w+="[^"]*")*\s*(?:/>|>\s*</embed>)!';
$old_regexp_ent = str_replace( '&amp;#0*58;', '&amp;#0*58;|&#0*58;', htmlspecialchars( $old_regexp, ENT_NOQUOTES ) );
Expand Down

1 comment on commit e4c966d

@andfinally
Copy link
Contributor

@andfinally andfinally commented on e4c966d Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to try this out, but I'm wondering if we need to escape the literal . characters, i.e. www\.youtube\.com/v/

Please sign in to comment.