Skip to content

Commit

Permalink
Fix usage of preg_quote() (#10998)
Browse files Browse the repository at this point in the history
The end tag pattern is currently generated like this:
```
$end_tag_pattern = '/<!--\s+\/wp:' . str_replace( '/', '\/', preg_quote( $block_name ) ) . '\s+-->/';
```

Instead of separately using a string replace to replace `/` with `\/`, it is preferable to use the second argument `$delimiter` that the `preg_quote()` function provides.

See http://php.net/manual/en/function.preg-quote.php
  • Loading branch information
schlessera authored and aduth committed Oct 25, 2018
1 parent fb9fa03 commit a696e50
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function do_blocks( $content ) {
$inner_content = '';

if ( ! $is_self_closing ) {
$end_tag_pattern = '/<!--\s+\/wp:' . str_replace( '/', '\/', preg_quote( $block_name ) ) . '\s+-->/';
$end_tag_pattern = '/<!--\s+\/wp:' . preg_quote( $block_name, '/' ) . '\s+-->/';
if ( ! preg_match( $end_tag_pattern, $content, $block_match_end, PREG_OFFSET_CAPTURE ) ) {
// If no closing tag is found, abort all matching, and continue
// to append remainder of content to rendered output.
Expand Down

0 comments on commit a696e50

Please sign in to comment.