Skip to content

Commit 410089d

Browse files
committed
Minimize groups and string interpolation
Add regex pattern explanation
1 parent b9f0cef commit 410089d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/wp-includes/html-api/class-wp-html-tag-processor.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3851,12 +3851,19 @@ public function set_modifiable_text( string $plaintext_content ): bool {
38513851
*/
38523852
if ( $this->is_javascript_script_tag() ) {
38533853
$plaintext_content = preg_replace_callback(
3854-
'~<(/?)(s)(cript)([\t\r\n\f />])~i',
3854+
/*
3855+
* This case-insensitive pattern consists of three groups:
3856+
*
3857+
* 1: "<" or "</"
3858+
* 2: "s"
3859+
* 3: "cript" + a trailing character that terminates a tag name.
3860+
*/
3861+
'~(</?)(s)(cript[\\t\\r\\n\\f />])~i',
38553862
static function ( $matches ) {
38563863
$escaped_s_char = 's' === $matches[2]
38573864
? '\\u0073'
38583865
: '\\u0053';
3859-
return "<{$matches[1]}{$escaped_s_char}{$matches[3]}{$matches[4]}";
3866+
return "{$matches[1]}{$escaped_s_char}{$matches[3]}";
38603867
},
38613868
$plaintext_content
38623869
);

0 commit comments

Comments
 (0)