@@ -179,6 +179,45 @@ void main() {
179179 );
180180 });
181181
182+ for (final saved in [false , true ]) {
183+ for (final rejection in ['oversized' , 'invalid MIME' , 'HTTP failure' ]) {
184+ test ('$rejection never exposes an unchecked URL, saved=$saved ' , () async {
185+ final container = containerFor ((request) async {
186+ if (request.url.path == '/' ) {
187+ return http.Response (
188+ '{"icon":"https://relay.example.com/rejected.png"}' ,
189+ 200 ,
190+ );
191+ }
192+ return http.Response .bytes (
193+ List .filled (rejection == 'oversized' ? 256 * 1024 + 1 : 4 , 0 ),
194+ rejection == 'HTTP failure' ? 503 : 200 ,
195+ headers: {
196+ 'content-type' : rejection == 'invalid MIME'
197+ ? 'text/html'
198+ : 'image/png' ,
199+ },
200+ );
201+ });
202+ if (saved) {
203+ await container
204+ .read (communityIconCacheProvider.notifier)
205+ .remember (key, artwork);
206+ }
207+ final presentation = communityIconPresentationProvider (relay);
208+ final subscription = container.listen (presentation, (_, _) {});
209+ addTearDown (subscription.close);
210+ final expected = saved ? artwork : null ;
211+ expect (
212+ await container.read (communityIconProvider (relay).future),
213+ expected,
214+ );
215+ expect (container.read (presentation), expected);
216+ expect (container.read (communityIconCacheProvider)[key], expected);
217+ });
218+ }
219+ }
220+
182221 test ('oversized downloads do not replace a usable saved image' , () async {
183222 final container = containerFor (
184223 (request) async => request.url.path == '/'
0 commit comments