Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion 4 src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ private JFifMarker(byte majorVersion, byte minorVersion, byte densityUnits, shor
/// <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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
11 changes: 11 additions & 0 deletions 11 tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,15 @@ public void Issue2315_DecodeWorks<TPixel>(TestImageProvider<TPixel> provider)
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);
}
}
1 change: 1 addition & 0 deletions 1 tests/ImageSharp.Tests/TestImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ public static class Issues
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
{
Expand Down
3 changes: 3 additions & 0 deletions 3 tests/Images/Input/Jpg/issues/issue-2478-jfxx.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.