ComputerGhost / FaviconFetcher

Scan a webpage for favicons, or just easily download the one you want.
MIT License
5 stars 3 forks source link

Some valid favicon's are not recognized due to EndOfStreamException #10

Closed kiddailey closed 1 year ago

kiddailey commented 1 year ago

I'm seeing some favicons not being processed due to an EndOfStreamException. Specifically, the following line in HttpSource.cs ExtractIcoSizes where it attempts to read the ICO header seems to be the culprit:

    stream.Seek(4000, SeekOrigin.Begin);
    var count = reader.ReadInt16();

According to FileFormat.com the total number of images in the ICO file starts at the 4th byte offset, not the 4000th. I'm not sure if I'm missing something or if this is a legitimate mistake, but when I change the line to be:

    stream.Seek(4, SeekOrigin.Begin);
    var count = reader.ReadInt16();

I seem to get much better and more consistent results. Will submit a pull request for this change in case you want to merge it.