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

Fixed classcast error in post processing of nodes #194

Merged
merged 1 commit into from
Oct 3, 2019
Merged

Fixed classcast error in post processing of nodes #194

merged 1 commit into from
Oct 3, 2019

Conversation

bjornri
Copy link
Contributor

@bjornri bjornri commented Oct 3, 2019

Hi

Noticed that when you use HtmlSanitizer.SanitizeDocument - the PostProcessNode event isn't called.
My current workaround is to use PostProcessDom instead and iterate over all the nodes in that event.
Tried to fix the bug with this PR.


When you use SanitizeDocument the 'context' parameter of DoPostProcess and RemoveComments is set to be the HTML document itself. The post processing require the context to be an IElement which isn't the case for AngleSharps HtmlDocument. Changed signatures of methods in post processing to use an INode instead. This allows the PostProcessNode event to be called when using SanitizeDocument.

When you use SanitizeDocument the 'context' parameter of DoPostProcess and RemoveComments is set to be the HTML document itself. The post processing require the context to be an IElement which isn't the case for AngleSharps HtmlDocument. Changed signatures of methods in post processing to use an INode instead. This allows the PostProcessNode event to be called when using SanitizeDocument.
@mganss mganss merged commit 8af548e into mganss:master Oct 3, 2019
@mganss
Copy link
Owner

mganss commented Oct 3, 2019

Nice catch, thank you.

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.

None yet

2 participants