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

Does NOT escape certain unicode characters #228

Open
sashasch opened this issue Apr 16, 2024 · 1 comment
Open

Does NOT escape certain unicode characters #228

sashasch opened this issue Apr 16, 2024 · 1 comment

Comments

@sashasch
Copy link

sashasch commented Apr 16, 2024

Hi j2html Team.

Overall I'm very excited from the library, thank you much!
Together with this I detected some behaviour which looks like a bug, some unicode characters are not (html) escaped:
Here the simple test:

  @Test
   @DisplayName("test escaping")
   void testEscaping() {
       String spacers = "\u00a0\u200c";
       assertEquals(" ‌",StringEscapeUtils.escapeHtml4(spacers));
       assertEquals(" ‌", TagCreator.text(spacers).render());
   }

The first assertion passes, because StringEscapeUtils of apache-commons does the job,
but the second assertion fails because the text left intact.
Using the last 1.6.0 version of the library.

Please advice!

@sashasch
Copy link
Author

Currently using the following workaround: escaping the spacers manually whenever it should be in my html and using rawHtml to prevent double encoding, because the library does escape the ampersand '&', but the solution looks not so good, because:

  • There is some small probability that the characters will appear in some other, unexpected places, like a user inputs.
  • There is some probability that the library doesn't escape some other, more frequently used characters.

@sashasch sashasch changed the title Not escapes certain characters Does NOT escape certain unicode characters Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant