Skip to content
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

JSoup differs from browsers around commented HTML attributes #1938

Closed
panthony opened this issue Apr 18, 2023 · 3 comments
Closed

JSoup differs from browsers around commented HTML attributes #1938

panthony opened this issue Apr 18, 2023 · 3 comments
Labels
Milestone

Comments

@panthony
Copy link

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.

@panthony
Copy link
Author

Probably a similar issue than #1483 except here it comment pretty much all the HTML.

@jhy
Copy link
Owner

jhy commented Apr 25, 2023

Yes I believe @panthony is right -- the browsers aren't treating this as a comment but as attributes on the div tag, like:

<div
  Attr: <!--
  Attr: id = hidden
  Attr: --
>

Will need to revisit #1483, either implement my idea or scrap the attempt to handle missing > and just hard follow the spec.

@jhy jhy closed this as completed in 28db617 Nov 24, 2024
@jhy
Copy link
Owner

jhy commented Nov 24, 2024

Thanks - resolved with #1483. Revalidated in browser and jsoup.

@jhy jhy added this to the 1.18.2 milestone Nov 24, 2024
@jhy jhy added the fixed label Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants