Commit 72a29cef78 for wordpress.org
commit 72a29cef78c30b43ece1ca0cd6ad35c62d58451c
Author: cbravobernal <cbravobernal@git.wordpress.org>
Date: Mon Nov 18 13:07:17 2024 +0000
HTML API: Fix normalized doctype pub/sys identifier quotes.
Changeset [59399] fixed missing DOCTYPEs in normalized HTML output. It missed an edge case where public and system identifiers may contain double quotes, in which case they must be quoted with single quotes.
This commit addresses that issue and adds tests.
Follow-up to [59399].
Props jonsurrell, luisherranz, apermo.
Fixes #62396.
Built from https://develop.svn.wordpress.org/trunk@59410
git-svn-id: http://core.svn.wordpress.org/trunk@58796 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/html-api/class-wp-html-processor.php b/wp-includes/html-api/class-wp-html-processor.php
index f6c561f010..9abc782d0c 100644
--- a/wp-includes/html-api/class-wp-html-processor.php
+++ b/wp-includes/html-api/class-wp-html-processor.php
@@ -1191,14 +1191,17 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
}
if ( null !== $doctype->public_identifier ) {
- $html .= " PUBLIC \"{$doctype->public_identifier}\"";
+ $quote = str_contains( $doctype->public_identifier, '"' ) ? "'" : '"';
+ $html .= " PUBLIC {$quote}{$doctype->public_identifier}{$quote}";
}
if ( null !== $doctype->system_identifier ) {
if ( null === $doctype->public_identifier ) {
$html .= ' SYSTEM';
}
- $html .= " \"{$doctype->system_identifier}\"";
+ $quote = str_contains( $doctype->system_identifier, '"' ) ? "'" : '"';
+ $html .= " {$quote}{$doctype->system_identifier}{$quote}";
}
+
$html .= '>';
break;
diff --git a/wp-includes/version.php b/wp-includes/version.php
index cdbfc94557..3e2d9added 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '6.8-alpha-59409';
+$wp_version = '6.8-alpha-59410';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.