Browse Source

[fix]: Fixed Unknown App0 Marker add profileResolver missing

pull/2566/head
Jose Elias dos Santos 2 years ago
parent
commit
c7f3aa40cb
  1. 3
      src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs
  2. 8
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs
  3. 11
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
  4. 1
      tests/ImageSharp.Tests/TestImages.cs
  5. 3
      tests/Images/Input/Jpg/issues/issue-2564.jpg

3
src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs

@ -73,7 +73,8 @@ internal readonly struct JFifMarker : IEquatable<JFifMarker>
{
// Some images incorrectly use JFXX as the App0 marker (Issue 2478)
if (ProfileResolver.IsProfile(bytes, ProfileResolver.JFifMarker)
|| ProfileResolver.IsProfile(bytes, ProfileResolver.JFxxMarker))
|| ProfileResolver.IsProfile(bytes, ProfileResolver.JFxxMarker)
|| ProfileResolver.IsProfile(bytes, ProfileResolver.OSQidMaker))
{
byte majorVersion = bytes[5];
byte minorVersion = bytes[6];

8
src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs

@ -24,6 +24,14 @@ internal static class ProfileResolver
(byte)'J', (byte)'F', (byte)'X', (byte)'X', (byte)'\0'
};
/// <summary>
/// Gets the \n[ID or 10 91 73 68 32 specific markers.
/// </summary>
public static ReadOnlySpan<byte> OSQidMaker => new[]
{
(byte)'\n', (byte)'[', (byte)'I', (byte)'D', (byte)' '
};
/// <summary>
/// Gets the ICC specific markers.
/// </summary>

11
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs

@ -326,6 +326,17 @@ public partial class JpegDecoderTests
image.CompareToOriginal(provider);
}
// https://github.com/SixLabors/ImageSharp/discussions/2564
[Theory]
[WithFile(TestImages.Jpeg.Issues.Issue2564, PixelTypes.Rgba32)]
public void Issue2564_DecodeWorks<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage(JpegDecoder.Instance);
image.DebugSave(provider);
image.CompareToOriginal(provider);
}
[Theory]
[WithFile(TestImages.Jpeg.Issues.HangBadScan, PixelTypes.L8)]
public void DecodeHang<TPixel>(TestImageProvider<TPixel> provider)

1
tests/ImageSharp.Tests/TestImages.cs

@ -291,6 +291,7 @@ public static class TestImages
public const string Issue2334_NotEnoughBytesA = "Jpg/issues/issue-2334-a.jpg";
public const string Issue2334_NotEnoughBytesB = "Jpg/issues/issue-2334-b.jpg";
public const string Issue2478_JFXX = "Jpg/issues/issue-2478-jfxx.jpg";
public const string Issue2564 = "Jpg/issues/issue-2564.jpg";
public const string HangBadScan = "Jpg/issues/Hang_C438A851.jpg";
public static class Fuzz

3
tests/Images/Input/Jpg/issues/issue-2564.jpg

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:08f215c777b6fe8e315f18b7f93611c90fa86fefb8e3d37181890afb3068d8bd
size 939150
Loading…
Cancel
Save