James Jackson-South
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
26 additions and
1 deletions
-
src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs
-
src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs
-
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
-
tests/ImageSharp.Tests/TestImages.cs
-
tests/Images/Input/Jpg/issues/issue-2478-jfxx.jpg
|
|
|
@ -71,7 +71,9 @@ internal readonly struct JFifMarker : IEquatable<JFifMarker> |
|
|
|
/// <param name="marker">The marker to return.</param>
|
|
|
|
public static bool TryParse(ReadOnlySpan<byte> bytes, out JFifMarker marker) |
|
|
|
{ |
|
|
|
if (ProfileResolver.IsProfile(bytes, ProfileResolver.JFifMarker)) |
|
|
|
// Some images incorrectly use JFXX as the App0 marker (Issue 2478)
|
|
|
|
if (ProfileResolver.IsProfile(bytes, ProfileResolver.JFifMarker) |
|
|
|
|| ProfileResolver.IsProfile(bytes, ProfileResolver.JFxxMarker)) |
|
|
|
{ |
|
|
|
byte majorVersion = bytes[5]; |
|
|
|
byte minorVersion = bytes[6]; |
|
|
|
|
|
|
|
@ -16,6 +16,14 @@ internal static class ProfileResolver |
|
|
|
(byte)'J', (byte)'F', (byte)'I', (byte)'F', (byte)'\0' |
|
|
|
}; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the JFXX specific markers.
|
|
|
|
/// </summary>
|
|
|
|
public static ReadOnlySpan<byte> JFxxMarker => new[] |
|
|
|
{ |
|
|
|
(byte)'J', (byte)'F', (byte)'X', (byte)'X', (byte)'\0' |
|
|
|
}; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the ICC specific markers.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
@ -314,4 +314,15 @@ public partial class JpegDecoderTests |
|
|
|
image.DebugSave(provider); |
|
|
|
image.CompareToOriginal(provider); |
|
|
|
} |
|
|
|
|
|
|
|
// https://github.com/SixLabors/ImageSharp/issues/2478
|
|
|
|
[Theory] |
|
|
|
[WithFile(TestImages.Jpeg.Issues.Issue2478_JFXX, PixelTypes.Rgba32)] |
|
|
|
public void Issue2478_DecodeWorks<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
|
{ |
|
|
|
using Image<TPixel> image = provider.GetImage(JpegDecoder.Instance); |
|
|
|
image.DebugSave(provider); |
|
|
|
image.CompareToOriginal(provider); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -290,6 +290,7 @@ public static class TestImages |
|
|
|
public const string Issue2315_NotEnoughBytes = "Jpg/issues/issue-2315.jpg"; |
|
|
|
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 static class Fuzz |
|
|
|
{ |
|
|
|
|
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
oid sha256:6bd5d14cbbead348404511801d7a2bacab19174e9f4063b5d2cec96f28fd578e |
|
|
|
size 300170 |