Skip to content

JSoup differs from browsers around commented HTML attributes #1938

@panthony

Description

@panthony

Hi,

I encountered a case where JSoup differs from what browsers (Chrome, Firefox Safari) do.

Using this piece of HTML on try jsoup:

<html>
<head>
<title>Try jsoup</title>
</head>
<body>
  <h1>before</h1>
  <div <!--="" id="hidden" --="">
      <h1>within</h1>
  </div>
   <h1>after</h1>
</body>
</html>

Jsoup will produce:

<html>
 <head>
  <title>Try jsoup</title>
 </head>
 <body>
  <h1>before</h1>
  <div>
   <!--="" id="hidden" --="">
      <h1>within</h1>
  </div>
   <h1>after</h1>
</body>
</html>
-->
  </div>
 </body>
</html>

Commenting the rest of the body whereas all major navigators will escape the comment character and shows the 3 titles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedAn {bug|improvement} that has been {fixed|implemented}

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions