Uploaded image for project: 'XWiki Commons'
  1. XWiki Commons
  2. XCOMMONS-907

HTML Cleaner removes the xmlns attribute even when it's set to be namespace-aware

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 7.4.1, 8.0-milestone-1
    • 6.4
    • XML
    • None
    • N/A
    • N/A

    Description

      Unit test to prove it:

          /**
           * Verify that a xmlns namespace set on the HTML element is not removed by default and it's removed if
           * {@link HTMLCleanerConfiguration#NAMESPACES_AWARE} is set to false.
           */
          @Test
          public void cleanHTMLTagWithNamespace() throws Exception
          {
              String input = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>";
      
              // Default
              Assert.assertEquals(HEADER + input + FOOTER,
                  HTMLUtils.toString(this.mocker.getComponentUnderTest().clean(new StringReader(input))));
      
              // Configured for namespace awareness being false
              HTMLCleanerConfiguration config = this.mocker.getComponentUnderTest().getDefaultConfiguration();
              config.setParameters(Collections.singletonMap(HTMLCleanerConfiguration.NAMESPACES_AWARE, "false"));
              Assert.assertEquals(HEADER + "<html><head></head><body>" + FOOTER,
                  HTMLUtils.toString(this.mocker.getComponentUnderTest().clean(new StringReader(input), config)));
          }
      

      The issue is with our custom serialization which removes it.

      Attachments

        Issue Links

          Activity

            People

              vmassol Vincent Massol
              vmassol Vincent Massol
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: