Make WordPress Core


Ignore:
Timestamp:
11/18/2024 01:37:52 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].

Reviewed by cbravobernal.
Merges [59410] to the 6.7 branch.

Props jonsurrell, luisherranz, apermo.
Fixes #62396.

Location:
branches/6.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.7

  • branches/6.7/src/wp-includes/html-api/class-wp-html-processor.php

    r59401 r59411  
    11711171
    11721172                if ( null !== $doctype->public_identifier ) {
    1173                     $html .= " PUBLIC \"{$doctype->public_identifier}\"";
     1173                    $quote = str_contains( $doctype->public_identifier, '"' ) ? "'" : '"';
     1174                    $html .= " PUBLIC {$quote}{$doctype->public_identifier}{$quote}";
    11741175                }
    11751176                if ( null !== $doctype->system_identifier ) {
     
    11771178                        $html .= ' SYSTEM';
    11781179                    }
    1179                     $html .= " \"{$doctype->system_identifier}\"";
    1180                 }
     1180                    $quote = str_contains( $doctype->system_identifier, '"' ) ? "'" : '"';
     1181                    $html .= " {$quote}{$doctype->system_identifier}{$quote}";
     1182                }
     1183
    11811184                $html .= '>';
    11821185                break;
Note: See TracChangeset for help on using the changeset viewer.