beautifier/js-beautify

HTML format breaks when text contains un-encoded <

Open

#1,646 建立於 2019年3月22日

在 GitHub 查看
 (6 留言) (0 反應) (0 負責人)JavaScript (1,460 fork)batch import
good first issuelanguage: htmltype: bug

倉庫指標

Star
 (8,342 star)
PR 合併指標
 (平均合併 51天 1小時) (30 天內合併 16 個 PR)

描述

Input

The code looked like this before beautification:

<!doctype html>
<html>

<body>
  <div>
    <button id="test">test < test</button>
  </div>
</body>

</html>

Expected Output

The code should have looked like this after beautification:

<!doctype html>
<html>

	<body>
		<div>
			<button id="test">test %3C test</button>
		</div>
	</body>

</html>

or

<!doctype html>
<html>

	<body>
		<div>
			<button id="test">test < test</button>
		</div>
	</body>

</html>

Actual Output

The code actually looked like this after beautification:

<!doctype html>
<html>

	<body>
		<div>
			<button id="test">test < test</button> </div> </body> </html>

This is using 1.9.0 on the online testing site.

I would assume you could take care of encoding the < while parsing. I personally think it would be fine to return it back encoded, but I'm not sure what your feelings on that part are, or if you even want to support it at all. I got an issue on it so I figured I would run it up the chain.

As a side note to save you a couple minutes I tried and having > in the text works as expected.

貢獻者指南