Skip to content

Modify a #text node name causes a StackOverflowException #548

Closed
@BrianPainter88

Description

Here is what to include in your request to make sure we implement a solution as quickly as possible.

1. Description

My application is using a process in which it loops through certain nodes and removes any namespaces that may be appended to the name. After the upgrade to version 1.11.48, a StackOverflowException is encountered when updating the HtmlNode.Name property and attempting to access either the HtmlNode.InnerHtml or HtmlNode.InnerText properties.

2. Exception

Exception of type 'System.StackOverflowException' was thrown.

3. Fiddle or Project

https://dotnetfiddle.net/Q1LM01

using System;
using HtmlAgilityPack;

public class Program
{
	public static void Main()
	{
		var document = new HtmlDocument();
		document.LoadHtml("a");

		foreach (var node in document.DocumentNode.ChildNodes)
		{
			if (node.Name == "#text")
			{
				node.Name = node.Name;
			}
		}
		
		foreach (var node in document.DocumentNode.ChildNodes)
		{
			Console.WriteLine(node.InnerHtml);
		}
	}
}

4. Any further technical details

Add any relevant detail can help us, such as:

  • HAP version: started in 1.11.48
  • NET version: any

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions