htacg / tidy-html5

The granddaddy of HTML tools, with support for modern standards
http://www.html-tidy.org
2.72k stars 420 forks source link

Tidy gets stuck in a loop #1021

Open David-Apps opened 2 years ago

David-Apps commented 2 years ago

Tidy gets stuck inside a loop.

I used HTML Tidy for Linux/x86 version 5.9.17.

Input:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Tidy gets stuck in a loop</title>
</head>
<body>
<table>
<tr>
<td>
<a>
<a href="#">b</a>
</a>
</td>
</tr>
</table>
</body>
</html>

Output:

line 11 column 1 - Warning: missing </a> before <a>
line 12 column 1 - Warning: inserting implicit <a>
line 12 column 1 - Warning: missing </a> before <a>
line 12 column 1 - Warning: inserting implicit <a>
line 12 column 1 - Warning: missing </a> before <a>
line 12 column 1 - Warning: inserting implicit <a>
line 12 column 1 - Warning: missing </a> before <a>
line 12 column 1 - Warning: inserting implicit <a>
line 12 column 1 - Warning: missing </a> before <a>
line 12 column 1 - Warning: inserting implicit <a>
...
cwshugg commented 1 year ago

Bumping this issue - I've found the bug as well on the most recent commit (2023-02-22, d08ddc28). Here's a smaller test case that produces the same behavior:

<!D a><li <a <a h