Conversation
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
|
Note also that the behavior of From the PHP docs at http://php.net/manual/en/function.preg-quote.php : |
|
|
||
| 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+-->/'; |
There was a problem hiding this comment.
this is a great change. but…while we're at it, what if we changed the delimiter too so remove a tiny bit of escaping?
'~<!--\s+/wp:' . preg_quote( $block_name, '~' ) . '\s+-->~'just a thought, but it only saves one escape 🤷♂️
dmsnell
left a comment
There was a problem hiding this comment.
This seems like a good change to me from the code perspective!
aduth
left a comment
There was a problem hiding this comment.
Second argument seems to have been designed for this, so makes total sense 👍
#10998 (comment) also seems reasonable, though not strictly related to what's being proposed for improvement here. Worth a separate issue / ticket?
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
…rnmobile/merge-blocks-on-backspace * 'master' of https://github.com/WordPress/gutenberg: Do not add isDirty prop to DOM (#11093) Format API (#10209) Remove 4.2 deprecated features (#10952) Update `@wordpress/hooks` README to include namespace mention (#11061) Feature: save lock control via actions (#10649) Fix usage of `preg_quote()` (#10998) Update plugin version to 4.1.1 (#11078) Improve preloading request code (#11007) Fix dynamic blocks not rendering in the frontend (#11050) Media & Text: Fixing vertical alignment of the image (#11025) Date: Mark getSettings as experimental (#10636) Improve handling of centered 1-col galleries with small images (#11040) Use better help text for ALT text input; fixes #8391. (#11052) # Conflicts: # packages/editor/src/components/rich-text/index.native.js

The end tag pattern is currently generated like this:
Instead of separately using a string replace to replace
/with\/, it is preferable to use the second argument$delimiterthat thepreg_quote()function provides.See http://php.net/manual/en/function.preg-quote.php