@Test
void escapeHTMLCharsInAttributes() throws Exception
{

    // Note: single quotes are not escaped since they're valid chars in attribute values that are surrounded by
    // quotes. And HTMLCleaner will convert single quoted attributes into double-quoted ones.
    String htmlInput = "<div foo=\"aaa&quot;bbb&amp;ccc&gt;ddd&lt;eee&apos;fff\">content</div>";
    Document document = this.cleaner.clean(new StringReader(htmlInput));
    String textContent =
        document.getElementsByTagName("div").item(0).getAttributes().getNamedItem("foo").getTextContent();
    assertEquals("aaa\"bbb&ccc>ddd<eee'fff", textContent);
    htmlInput = "<div foo='aaa&quot;bbb&amp;ccc&gt;ddd&lt;eee&apos;fff'>content</div>";
    document = this.cleaner.clean(new StringReader(htmlInput));
    textContent =
        document.getElementsByTagName("div").item(0).getAttributes().getNamedItem("foo").getTextContent();
    assertEquals("aaa\"bbb&ccc>ddd<eee'fff", textContent);
    assertHTML("<div foo=\"aaa&quot;bbb&amp;ccc&gt;ddd&lt;eee'fff\">content</div>",
        "<div foo=\"aaa&quot;bbb&amp;ccc&gt;ddd&lt;eee&apos;fff\">content</div>");
    assertHTML("<div foo=\"aaa&quot;bbb&amp;ccc&gt;ddd&lt;eee'fff\">content</div>",
        "<div foo='aaa&quot;bbb&amp;ccc&gt;ddd&lt;eee&apos;fff'>content</div>");
}