Make WordPress Core


Ignore:
Timestamp:
11/18/2024 01:05:35 PM (13 months ago)
Author:
cbravobernal
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/html-api/class-wp-html-processor.php

    r59399 r59410  
    11921192
    11931193                if ( null !== $doctype->public_identifier ) {
    1194                     $html .= " PUBLIC \"{$doctype->public_identifier}\"";
     1194                    $quote = str_contains( $doctype->public_identifier, '"' ) ? "'" : '"';
     1195                    $html .= " PUBLIC {$quote}{$doctype->public_identifier}{$quote}";
    11951196                }
    11961197                if ( null !== $doctype->system_identifier ) {
     
    11981199                        $html .= ' SYSTEM';
    11991200                    }
    1200                     $html .= " \"{$doctype->system_identifier}\"";
    1201                 }
     1201                    $quote = str_contains( $doctype->system_identifier, '"' ) ? "'" : '"';
     1202                    $html .= " {$quote}{$doctype->system_identifier}{$quote}";
     1203                }
     1204
    12021205                $html .= '>';
    12031206                break;
Note: See TracChangeset for help on using the changeset viewer.