Skip to content

Fixed an html encoding issue#97

Merged
valadas merged 2 commits into
DNNCommunity:developfrom
valadas:sanitize-encode
May 30, 2026
Merged

Fixed an html encoding issue#97
valadas merged 2 commits into
DNNCommunity:developfrom
valadas:sanitize-encode

Conversation

@valadas

@valadas valadas commented May 30, 2026

Copy link
Copy Markdown
Member

Closes #93

@stetard FYI

This is a classic issue of double encoding.

There are generally 2 parts to preventing XSS.

  1. Going from user input to the database should keep the normal raw formatting but sanitize the input to remove anything unexpected. In the case of normal strings like names and titles, that can be done with HtmlUtils.StripTags which will remove any html/script tags and only return a plain string without any tags. For html content it is a bit more complex and I will explain later.
  2. Encoding is the responsibility of the piece of code that deals with displaying that string, in this case we are dealing with webforms that goes directly into html, so we can use HtmlEncode, but that data could be exposed in json in a webapi or other mechanisms that might need different handling (hence why it is best practice to only sanitize and not encode in the database).

Now for html content is is slightly different:
We don't want to remove all tags but still sanitize for no scripts. There is a method for that in HtmlUtils.SanitizeHtmlIfNeeded.
I will merge this and do a new beta if you have existing data you can test this out with.

@valadas valadas added this to the 4.2.0 milestone May 30, 2026
@valadas valadas added the bug Something isn't working label May 30, 2026
@valadas valadas merged commit 2712664 into DNNCommunity:develop May 30, 2026
1 check passed
@valadas

valadas commented May 30, 2026

Copy link
Copy Markdown
Member Author

Oops, I merged into the wrong branch, will do an extra PR...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong display for the entry name and the author when they contain special chars included accents

1 participant