Skip to content

Commit d03b1d5

Browse files
Merge branch 'main' into sn/net10
2 parents fd04531 + 0b34bca commit d03b1d5

File tree

128 files changed

+889
-720
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+889
-720
lines changed

.github/workflows/build-and-test.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ jobs:
6262
needs: WarmLFS
6363
strategy:
6464
matrix:
65-
isARM:
66-
- ${{ contains(github.event.pull_request.labels.*.name, 'arch:arm32') || contains(github.event.pull_request.labels.*.name, 'arch:arm64') }}
6765
options:
6866
- os: ubuntu-latest
6967
framework: net10.0
@@ -77,13 +75,19 @@ jobs:
7775
sdk-preview: true
7876
runtime: -x64
7977
codecov: false
78+
- os: macos-26
79+
framework: net9.0
80+
sdk: 9.0.x
81+
sdk-preview: true
82+
runtime: -x64
83+
codecov: false
8084
- os: windows-latest
8185
framework: net10.0
8286
sdk: 10.0.x
8387
sdk-preview: true
8488
runtime: -x64
8589
codecov: false
86-
- os: buildjet-4vcpu-ubuntu-2204-arm
90+
- os: ubuntu-22.04-arm
8791
framework: net10.0
8892
sdk: 10.0.x
8993
sdk-preview: true
@@ -100,20 +104,21 @@ jobs:
100104
sdk: 8.0.x
101105
runtime: -x64
102106
codecov: false
107+
- os: macos-26
108+
framework: net8.0
109+
sdk: 8.0.x
110+
runtime: -x64
111+
codecov: false
103112
- os: windows-latest
104113
framework: net8.0
105114
sdk: 8.0.x
106115
runtime: -x64
107116
codecov: false
108-
- os: buildjet-4vcpu-ubuntu-2204-arm
117+
- os: ubuntu-22.04-arm
109118
framework: net8.0
110119
sdk: 8.0.x
111120
runtime: -x64
112121
codecov: false
113-
exclude:
114-
- isARM: false
115-
options:
116-
os: buildjet-4vcpu-ubuntu-2204-arm
117122

118123
runs-on: ${{ matrix.options.os }}
119124

@@ -124,6 +129,18 @@ jobs:
124129
sudo apt-get update
125130
sudo apt-get -y install libgdiplus libgif-dev libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev
126131
132+
- name: Install libgdi+, which is required for tests running on macos
133+
if: ${{ contains(matrix.options.os, 'macos-26') }}
134+
run: |
135+
brew update
136+
brew install mono-libgdiplus
137+
# Create symlinks to make libgdiplus discoverable
138+
sudo mkdir -p /usr/local/lib
139+
sudo ln -sf $(brew --prefix)/lib/libgdiplus.dylib /usr/local/lib/libgdiplus.dylib
140+
# Verify installation
141+
ls -la $(brew --prefix)/lib/libgdiplus* || echo "libgdiplus not found in brew prefix"
142+
ls -la /usr/local/lib/libgdiplus* || echo "libgdiplus not found in /usr/local/lib"
143+
127144
- name: Git Config
128145
shell: bash
129146
run: |

src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData
7171
/// </summary>
7272
private bool hasAdobeMarker;
7373

74+
/// <summary>
75+
/// Whether the image has a SOS marker.
76+
/// </summary>
77+
private bool hasSOSMarker;
78+
7479
/// <summary>
7580
/// Contains information about the JFIF marker.
7681
/// </summary>
@@ -197,6 +202,12 @@ protected override Image<TPixel> Decode<TPixel>(BufferedReadStream stream, Cance
197202
{
198203
using SpectralConverter<TPixel> spectralConverter = new(this.configuration, this.resizeMode == JpegDecoderResizeMode.ScaleOnly ? null : this.Options.TargetSize);
199204
this.ParseStream(stream, spectralConverter, cancellationToken);
205+
206+
if (!this.hasSOSMarker)
207+
{
208+
JpegThrowHelper.ThrowInvalidImageContentException("Missing SOS marker.");
209+
}
210+
200211
this.InitExifProfile();
201212
this.InitIccProfile();
202213
this.InitIptcProfile();
@@ -215,6 +226,12 @@ protected override Image<TPixel> Decode<TPixel>(BufferedReadStream stream, Cance
215226
protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken)
216227
{
217228
this.ParseStream(stream, spectralConverter: null, cancellationToken);
229+
230+
if (!this.hasSOSMarker)
231+
{
232+
JpegThrowHelper.ThrowInvalidImageContentException("Missing SOS marker.");
233+
}
234+
218235
this.InitExifProfile();
219236
this.InitIccProfile();
220237
this.InitIptcProfile();
@@ -403,6 +420,8 @@ internal void ParseStream(BufferedReadStream stream, SpectralConverter spectralC
403420
break;
404421

405422
case JpegConstants.Markers.SOS:
423+
424+
this.hasSOSMarker = true;
406425
if (!metadataOnly)
407426
{
408427
this.ProcessStartOfScanMarker(stream, markerContentByteSize);

src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ public ImageInfo Identify(
112112
this.webpMetadata = this.metadata.GetWebpMetadata();
113113
this.webpMetadata.RepeatCount = features.AnimationLoopCount;
114114

115-
Color backgroundColor = this.backgroundColorHandling == BackgroundColorHandling.Ignore
115+
this.webpMetadata.BackgroundColor = this.backgroundColorHandling == BackgroundColorHandling.Ignore
116116
? Color.Transparent
117117
: features.AnimationBackgroundColor!.Value;
118118

119-
this.webpMetadata.BackgroundColor = backgroundColor;
120-
119+
bool ignoreMetadata = this.skipMetadata;
120+
SegmentIntegrityHandling segmentIntegrityHandling = this.segmentIntegrityHandling;
121121
Span<byte> buffer = stackalloc byte[4];
122122
uint frameCount = 0;
123123
int remainingBytes = (int)completeDataSize;
@@ -135,9 +135,16 @@ public ImageInfo Identify(
135135

136136
remainingBytes -= (int)dataSize;
137137
break;
138+
case WebpChunkType.Iccp:
138139
case WebpChunkType.Xmp:
139140
case WebpChunkType.Exif:
140-
WebpChunkParsingUtils.ParseOptionalChunks(stream, chunkType, this.metadata, this.skipMetadata, this.segmentIntegrityHandling, buffer);
141+
WebpChunkParsingUtils.ParseOptionalChunks(
142+
stream,
143+
chunkType,
144+
this.metadata,
145+
ignoreMetadata,
146+
segmentIntegrityHandling,
147+
buffer);
141148
break;
142149
default:
143150

@@ -187,9 +194,12 @@ public Image<TPixel> Decode<TPixel>(
187194
this.webpMetadata.BackgroundColor = backgroundColor;
188195
TPixel backgroundPixel = backgroundColor.ToPixel<TPixel>();
189196

197+
bool ignoreMetadata = this.skipMetadata;
198+
SegmentIntegrityHandling segmentIntegrityHandling = this.segmentIntegrityHandling;
190199
Span<byte> buffer = stackalloc byte[4];
191200
uint frameCount = 0;
192201
int remainingBytes = (int)completeDataSize;
202+
193203
while (remainingBytes > 0)
194204
{
195205
WebpChunkType chunkType = WebpChunkParsingUtils.ReadChunkType(stream, buffer);
@@ -209,9 +219,10 @@ public Image<TPixel> Decode<TPixel>(
209219

210220
remainingBytes -= (int)dataSize;
211221
break;
222+
case WebpChunkType.Iccp:
212223
case WebpChunkType.Xmp:
213224
case WebpChunkType.Exif:
214-
WebpChunkParsingUtils.ParseOptionalChunks(stream, chunkType, image!.Metadata, this.skipMetadata, this.segmentIntegrityHandling, buffer);
225+
WebpChunkParsingUtils.ParseOptionalChunks(stream, chunkType, image!.Metadata, ignoreMetadata, segmentIntegrityHandling, buffer);
215226
break;
216227
default:
217228

0 commit comments

Comments
 (0)