Menu

#196 Empty String results in wrong output

v2.30
open
nobody
None
5
2023-06-19
2017-10-14
No

We use this configuration:

CleanerProperties props = new CleanerProperties();
    props.setOmitUnknownTags(false);
    props.setOmitXmlDeclaration(omitXmlDeclaration);
    props.setOmitHtmlEnvelope(true);
    props.setTransResCharsToNCR(true);
    props.setTransSpecialEntitiesToNCR(true);

And then we use this code to clean an html String called htmlString.

HtmlCleaner cleaner = new HtmlCleaner(props);
TagNode rootTag = cleaner.clean(htmlString);
XmlSerializer serializer = new SimpleXmlSerializer(props);
String cleanHtml = serializer.getAsString(rootTag);

Normally this works fine, but there is a special case this is not working.

Using the String " " (one blank sign, but with 2 or more it is also not working) is returned as "". So htmlString.equals(cleanHtml) is false.

Now, I use the String " check ". After cleaning this String with the code above the result is " check ". So everything's as expected. It seems that a String containing whitespaces is cleaned to an empty String. This is some unexpected :)

Can you pleas check this.

Discussion

  • Scott Wilson

    Scott Wilson - 2018-04-24
    • Group: v2.22 --> v2.23
     
  • Scott Wilson

    Scott Wilson - 2018-04-24

    Moing to 2.23 fix list

     
  • Scott Wilson

    Scott Wilson - 2019-09-04

    Its a puzzle all right. I suspect when the content node is created the collapse whitespace algorithm chops it down.

     
  • Scott Wilson

    Scott Wilson - 2019-09-04
    • Group: v2.23 --> v2.24
     
  • Scott Wilson

    Scott Wilson - 2020-04-29
    • Group: v2.24 --> v2.25
     
  • Scott Wilson

    Scott Wilson - 2021-09-24
    • Group: v2.25 --> v2.26
     
  • Scott Wilson

    Scott Wilson - 2023-04-29
    • Group: v2.26 --> v2.29
     
  • Scott Wilson

    Scott Wilson - 2023-06-19
    • Group: v2.29 --> v2.30
     

Log in to post a comment.

Auth0 Logo