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

DYN-3243: HTML Sanitizer fixes #11321

Merged
merged 2 commits into from
Dec 4, 2020
Merged

DYN-3243: HTML Sanitizer fixes #11321

merged 2 commits into from
Dec 4, 2020

Conversation

sm6srw
Copy link
Contributor

@sm6srw sm6srw commented Dec 3, 2020

Purpose

HTML Sanitizer fixes

This pull request does:

  • allow html content with a body to Sanitize as a document (e.g. head tags are allowed)
  • allow meta tags
  • allow style tags
  • allow content attributes
  • allow http-equiv attributes
  • allow src css properties
  • stop consider comments as a content change

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Reviewers

@mjkkirschner

FYIs

@sm6srw sm6srw requested a review from mjkkirschner December 3, 2020 23:18
var output = HtmlSanitizer.Sanitize(content);
if (content.Contains(@"<body "))
{
output = HtmlSanitizer.SanitizeDocument(content);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the difference between these two?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one sanitize a document, e.g. you have a body with an optional head. The other one is for sanitizing fragments. head is ignored for fragments and that was the problem here.

@mjkkirschner
Copy link
Member

@sm6srw will the current sanitization settings allow images embedded using data like this:
https://github.com/DynamoDS/Dynamo/blob/master/src/DocumentationBrowserViewExtension/Docs/FileNotFound.html#L57 ?

@sm6srw
Copy link
Contributor Author

sm6srw commented Dec 4, 2020

@sm6srw will the current sanitization settings allow images embedded using data like this:
https://github.com/DynamoDS/Dynamo/blob/master/src/DocumentationBrowserViewExtension/Docs/FileNotFound.html#L57 ?

Yes, I think so but I will give it a test.

@mjkkirschner
Copy link
Member

mjkkirschner commented Dec 4, 2020

This looks good @sm6srw but as we have seen - we should probably beef up our test cases. We can do that as a followup pr.

here are a few suggested test cases we can write up:

  • generated html contains correct styles
  • generated html contains data embedded image
  • generated html contains body.
  • generated html contains button (python docs message)

any ideas for others? I can help to write these up tomorrow.

@mjkkirschner
Copy link
Member

@sm6srw tests all pass - feel free to merge when you think it's ready.

@sm6srw sm6srw merged commit 3b99a7a into DynamoDS:master Dec 4, 2020
@sm6srw sm6srw deleted the DYN-3243 branch December 4, 2020 12:51
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

Successfully merging this pull request may close these issues.

2 participants