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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.4
    • Fix Version/s: 7.4.1, 8.0-milestone-1
    • Component/s: XML
    • Labels:
      None
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: