Skip to content

Incorrect error line numbers reported in Dom\HTMLDocument::createFromString #17486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xPaw opened this issue Jan 16, 2025 · 0 comments
Closed

Comments

@xPaw
Copy link
Contributor

xPaw commented Jan 16, 2025

Description

<?php

$repeated = str_repeat('a', 50000);

$html = <<<HTML
<!DOCTYPE html>
<html lang="en">
	<body>
		<svg>
			<path d="{$repeated}" />
		</svg>
		<div>&#xa;</div>
	</body>
</html>
HTML;

// this reports tokenizer error control-character-reference in Entity, line: 53, column: 883
$Document = \Dom\HTMLDocument::createFromString($html);

This only happens for tokenizer errors, but not tree errors: change &#xa; to <hr /> and it will correctly report line: 7, column: 9-10.


PHP Version

8.4.3

Operating System

No response

@nielsdos nielsdos self-assigned this Jan 16, 2025
nielsdos added a commit to nielsdos/php-src that referenced this issue Jan 16, 2025

Verified

This commit was signed with the committer’s verified signature.
nielsdos Niels Dossche
…ument::createFromString
nielsdos added a commit to nielsdos/php-src that referenced this issue Jan 16, 2025

Verified

This commit was signed with the committer’s verified signature.
nielsdos Niels Dossche
…ument::createFromString
nielsdos added a commit to nielsdos/php-src that referenced this issue Jan 16, 2025

Verified

This commit was signed with the committer’s verified signature.
nielsdos Niels Dossche
…ument::createFromString
nielsdos added a commit that referenced this issue Jan 17, 2025

Verified

This commit was signed with the committer’s verified signature.
nielsdos Niels Dossche
* PHP-8.4:
  Fix GH-17481: UTF-8 corruption in \Dom\HTMLDocument
  Fix GH-17486: Incorrect error line numbers reported in Dom\HTMLDocument::createFromString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants