Skip to content

Allow form feed characters in attributes #280

Description

@Rudloff

Tokenizer::quotedAttributeValue() has special handling for form feed characters.
(This used to also include newlines and tabs but was removed in 8785fc5.)

Because of this, if an attribute contains a form feed, everything after this character is ignored.

This creates a discrepancy between masterminds/html5 and the native DOM extension:

$html = "<img src='foo.png' alt='before \f after'>";

$html5 = new HTML5();
$dom = $html5->loadHTML($html);
echo $html5->saveHTML($dom);
// <img src="foo.png" alt="before ">

$dom = new DOMDocument();
$dom->loadHTML($html);
echo $dom->saveHTML();
// <img src="foo.png" alt="before  after">

This HTML containing a form feed character in the alt attribute is valid according to https://validator.w3.org/:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<img src="foo.png" alt=" foo">
</body>
</html>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions