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

Setting OptionCheckSyntax to false throws a NullReferenceException if html has unclosed tags #329

Closed
Shoh opened this issue Sep 13, 2019 · 4 comments
Assignees

Comments

@Shoh
Copy link

Shoh commented Sep 13, 2019

Description

When using the LoadHtml method of an HtmlDocument instance that has the property OptionCheckSyntax set to false, a NullReferenceException is thrown if the input HTML has any unclosed tags or is invalid in any way. I'm not sure if this is expected or As Designed but I couldn't find any information about it.

Exception

Exception message:  Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
Stack trace:
   at HtmlAgilityPack.HtmlNode.UpdateLastNode() in C:\Users\Jonathan\source\repos\HtmlAgilityPack\HtmlAgilityPack.Shared\HtmlNode.cs:line 2009
   at HtmlAgilityPack.HtmlNode.CloseNode(HtmlNode endnode, Int32 level) in C:\Users\Jonathan\source\repos\HtmlAgilityPack\HtmlAgilityPack.Shared\HtmlNode.cs:line 2077
   at HtmlAgilityPack.HtmlNode.CloseNode(HtmlNode endnode, Int32 level) in C:\Users\Jonathan\source\repos\HtmlAgilityPack\HtmlAgilityPack.Shared\HtmlNode.cs:line 2056
   at HtmlAgilityPack.HtmlDocument.CloseCurrentNode() in C:\Users\Jonathan\source\repos\HtmlAgilityPack\HtmlAgilityPack.Shared\HtmlDocument.cs:line 1077
   at HtmlAgilityPack.HtmlDocument.PushNodeEnd(Int32 index, Boolean close) in C:\Users\Jonathan\source\repos\HtmlAgilityPack\HtmlAgilityPack.Shared\HtmlDocument.cs:line 2061
   at HtmlAgilityPack.HtmlDocument.Parse() in C:\Users\Jonathan\source\repos\HtmlAgilityPack\HtmlAgilityPack.Shared\HtmlDocument.cs:line 1391
   at HtmlAgilityPack.HtmlDocument.Load(TextReader reader) in C:\Users\Jonathan\source\repos\HtmlAgilityPack\HtmlAgilityPack.Shared\HtmlDocument.cs:line 771
   at HtmlAgilityPack.HtmlDocument.LoadHtml(String html) in C:\Users\Jonathan\source\repos\HtmlAgilityPack\HtmlAgilityPack.Shared\HtmlDocument.cs:line 819
   at Program.Main()

Fiddle or Project

https://dotnetfiddle.net/9NZotJ

Further technical details

  • HAP version: 1.11.12
  • NET version: netcoreapp2.2
@JonathanMagnan JonathanMagnan self-assigned this Sep 16, 2019
@JonathanMagnan
Copy link
Member

Hello @Shoh ,

Thank you for reporting, we will look at why this issue happens.

Best Regards,

Jonathan


Performance Libraries
context.BulkInsert(list, options => options.BatchSize = 1000);
Entity Framework ExtensionsEntity Framework ClassicBulk OperationsDapper Plus

Runtime Evaluation
Eval.Execute("x + y", new {x = 1, y = 2}); // return 3
C# Eval FunctionSQL Eval Function

@JonathanMagnan
Copy link
Member

Hello @Shoh ,

The pull made by @EvgeniyZ has been finally merged. Thank to him!

Starting from the v1.11.15, you should no longer get the issue.

Let me know if everything works as expected.

Best Regards,

Jonathan

@JonathanMagnan
Copy link
Member

Hello @Shoh

Did you get the time to try the latest version v1.11.15?

Best Regards,

Jonathan

@Shoh
Copy link
Author

Shoh commented Oct 8, 2019

Hi @JonathanMagnan,

Sorry for the delay; I've been on vacation. Yes, I can confirm that the issue is fixed in v1.11.15. Thank you!

-Shoh

@Shoh Shoh closed this as completed Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants