Skip to content

Commit c7f3aa4

Browse files
[fix]: Fixed Unknown App0 Marker add profileResolver missing
1 parent d93bc6c commit c7f3aa4

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public static bool TryParse(ReadOnlySpan<byte> bytes, out JFifMarker marker)
7373
{
7474
// Some images incorrectly use JFXX as the App0 marker (Issue 2478)
7575
if (ProfileResolver.IsProfile(bytes, ProfileResolver.JFifMarker)
76-
|| ProfileResolver.IsProfile(bytes, ProfileResolver.JFxxMarker))
76+
|| ProfileResolver.IsProfile(bytes, ProfileResolver.JFxxMarker)
77+
|| ProfileResolver.IsProfile(bytes, ProfileResolver.OSQidMaker))
7778
{
7879
byte majorVersion = bytes[5];
7980
byte minorVersion = bytes[6];

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ internal static class ProfileResolver
2424
(byte)'J', (byte)'F', (byte)'X', (byte)'X', (byte)'\0'
2525
};
2626

27+
/// <summary>
28+
/// Gets the \n[ID or 10 91 73 68 32 specific markers.
29+
/// </summary>
30+
public static ReadOnlySpan<byte> OSQidMaker => new[]
31+
{
32+
(byte)'\n', (byte)'[', (byte)'I', (byte)'D', (byte)' '
33+
};
34+
2735
/// <summary>
2836
/// Gets the ICC specific markers.
2937
/// </summary>

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,17 @@ public void Issue2478_DecodeWorks<TPixel>(TestImageProvider<TPixel> provider)
326326
image.CompareToOriginal(provider);
327327
}
328328

329+
// https://github.com/SixLabors/ImageSharp/discussions/2564
330+
[Theory]
331+
[WithFile(TestImages.Jpeg.Issues.Issue2564, PixelTypes.Rgba32)]
332+
public void Issue2564_DecodeWorks<TPixel>(TestImageProvider<TPixel> provider)
333+
where TPixel : unmanaged, IPixel<TPixel>
334+
{
335+
using Image<TPixel> image = provider.GetImage(JpegDecoder.Instance);
336+
image.DebugSave(provider);
337+
image.CompareToOriginal(provider);
338+
}
339+
329340
[Theory]
330341
[WithFile(TestImages.Jpeg.Issues.HangBadScan, PixelTypes.L8)]
331342
public void DecodeHang<TPixel>(TestImageProvider<TPixel> provider)

tests/ImageSharp.Tests/TestImages.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ public static class Issues
291291
public const string Issue2334_NotEnoughBytesA = "Jpg/issues/issue-2334-a.jpg";
292292
public const string Issue2334_NotEnoughBytesB = "Jpg/issues/issue-2334-b.jpg";
293293
public const string Issue2478_JFXX = "Jpg/issues/issue-2478-jfxx.jpg";
294+
public const string Issue2564 = "Jpg/issues/issue-2564.jpg";
294295
public const string HangBadScan = "Jpg/issues/Hang_C438A851.jpg";
295296

296297
public static class Fuzz
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)