Maximum recursion depth
See original GitHub issueNew Feature Proposal
Description
Add possibility to restrict recursion depth to a maximum number.
Background
We use AngleSharp to parse E-Mails. Those can come from good people and from bad (Spam). In the latter case, the E-Mails often contain invalid tags and invalid HTML. Currently we run into issues with following stuff:
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
And this is only a small piece. The original email is about ten times longer.
This one leads to a StackOverflow in CollectionExtensions.GetAllElements<T>(this INode parent, Predicate<T> predicate)
while accessing child nodes.
Of course I know that the maximum depth depends on several factors, e.g. from where the code is called and how much is on the stack.
Any other suggestions to solve this issue?
//Edit: maybe we are able to use a iterative solution instead of a recursive one. Are there any reasons for the current choice?
Specification
Issue Analytics
- State:
- Created 5 years ago
- Comments:22 (12 by maintainers)
Top GitHub Comments
@FlorianRappl please see this gist: https://gist.github.com/gabbersepp/033b5a1fa93f055a8b1d816db5cdcaf3
I have removed all sensible information.
@FlorianRappl Hey I will send you an example next week.