Skip to content

ParseStyleSheetAsync throws NPE on empty string #42

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

Closed
4 of 5 tasks
Fraaankes opened this issue Oct 22, 2019 · 2 comments
Closed
4 of 5 tasks

ParseStyleSheetAsync throws NPE on empty string #42

Fraaankes opened this issue Oct 22, 2019 · 2 comments
Assignees
Milestone

Comments

@Fraaankes
Copy link

Fraaankes commented Oct 22, 2019

Bug Report

Prerequisites

  • Can you reproduce the problem in a MWE?
  • Are you running the latest version of AngleSharp?
  • Did you check the FAQs to see if that helps you?
  • Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Css for CSS support)
  • Did you perform a search in the issues?

For more information, see the CONTRIBUTING guide.

Description

Calling CssParser.ParseStyleSheetAsync("") throws a System.NullReferenceException.

Steps to Reproduce

Code:

class Program
    {
        static async Task Main(string[] args)
        {
            var parser = new CssParser();
            var s = await parser.ParseStyleSheetAsync("");

            Console.WriteLine(s);
        }
    }

Stacktrace:
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at AngleSharp.Text.TextSource.DetectByteOrderMarkAsync(CancellationToken cancellationToken)
at AngleSharp.Text.TextSource.PrefetchAllAsync(CancellationToken cancellationToken)
at AngleSharp.Css.Parser.CssParser.ParseStyleSheetAsync(String content, CancellationToken cancelToken)

Expected behavior: [What you expected to happen]
To behave like the non-async version which correctly parses the empty string and returns an empty stylesheet.

Environment details: [OS, .NET Runtime, ...]
Windows 10
.NET Core 3.0.100

@Fraaankes Fraaankes added the bug label Oct 22, 2019
@FlorianRappl FlorianRappl self-assigned this Oct 22, 2019
@FlorianRappl
Copy link
Contributor

Thanks for the report. I'll look into it!

@FlorianRappl FlorianRappl added this to the v0.14 milestone Apr 4, 2020
@FlorianRappl
Copy link
Contributor

Landed in devel and the preview on NuGet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants