-
Notifications
You must be signed in to change notification settings - Fork 70
fix: Do not strip whitespaces when sanitizing html #5540
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
Conversation
@@ -270,13 +270,17 @@ private String getDeltaValue() { | |||
} | |||
|
|||
static String sanitize(String html) { | |||
return org.jsoup.Jsoup.clean(html, | |||
org.jsoup.nodes.Document.OutputSettings settings = new org.jsoup.nodes.Document.OutputSettings(); | |||
settings.prettyPrint(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to fix the original issue. You can try it with the following:
editor.asDelta().setValue(
"[{\"attributes\":{\"bold\":true},\"insert\":\"Line 1\"},{\"insert\":\"\\n" + //
"\\tIndent 1\\n" + //
"\\t\\tIndent 2\\n" + //
"Last line with\\textra spaces and a \\ttab\\n" + //
"\\n" + //
"\"}] ");
In fact, the result is the same even if you return the given html
as such from the sanitize
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to dig this deeper. It may be that the fix needs changes in web component as well. Or if the white spaces are stripped also in Quill. If the later, we are stuck. If it is not the trouble maker, i.e. issue in our code, this Java side change is needed anyway, but if it is Quill related, this change is meaningless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did some more investigation. This is actually a proper fix for the Flow RichTextEditor. To fully cover the original issue, another fix to the Web Component is also required. I'm working on that now. Once the Web Component with the fix is available, we can merge this change and close the issue.
We will proceed with PR once WC alpha6 is available. |
SonarCloud Quality Gate failed.
|
Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com>
Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com>
This ticket/PR has been released with Vaadin 24.3.0.alpha2 and is also targeting the upcoming stable 24.3.0 version. |
Fixes #5533
Depends on vaadin/web-components#6651