Correzioni della revisione della catena 0.3.0, ognuna con la sua prova
- Collegamento: corretta la SyntaxError di connection.js (una «let saved» dichiarata due
volte nello stesso blocco fermava tutta la pagina). Nuova prova ScriptSyntaxTests con un
controllo scritto in casa che legge ogni modulo di wwwroot: parentesi, dichiarazioni
doppie nello stesso blocco, importazioni che il modulo di arrivo non esporta.
- HEIF: il riconoscimento dei formati prende ogni marchio che HeifDecoder accetta (mif2,
MiHE, marchi solo compatibili), così rilevazione, decodifica, misure, miniatura e
impronta concordano.
- Docker, lasciare la pagina del browser: un nuovo contratto del browser cancella l'uscita
annotata (_leftAt) anche prima che la vista si riapra, e la copia della sessione aspetta
un altro comando del collegamento al più LetGoWait invece che senza limite.
- JPEG e PNG: senza EOI o IEND la decodifica fallisce («File danneggiato o incompleto»),
la sola lettura delle misure resta tollerante.
- Visualizzatore: IsDamaged legge prima l'intestazione e il file intero solo quando può
servire, in modo asincrono e con una piccola memoria per file, così una scheda con
molti file non blocca il server.
- Importazione (§9.3): le immagini danneggiate si importano come le altre ma si segnano
nella revisione, nel resoconto e nel CSV.
- Pulizia: le prove con il limite di 5 minuti non corrono più in parallelo fra loro.
- Pila dei caratteri come l'appendice B, senza Liberation; testo di Informazioni sulle
immagini fatte in casa; guida (Problemi comuni, Sicurezza) allineata all'uscita in
Docker dalla pagina del browser.
- docs/decisioni.md: le righe del 25 novembre 2026 con i motivi, compresa l'unione 537517b
tenuta così com'è.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3d234f8791
commit
2068dd28f3
35 files changed
+1366
-75
No files matched your search
@@ -23,7 +23,10 @@ public enum ImageFormat
|
||||
/// <summary>Recognises an image format from the first bytes of a file.</summary>
|
||||
public static class ImageFormatSniffer
|
||||
{
|
||||
/// <summary>Bytes <see cref="Detect"/> needs to tell every format apart; fewer are fine for most formats.</summary>
|
||||
/// <summary>
|
||||
/// Bytes <see cref="Detect"/> needs to tell every format apart; fewer are fine for most formats. A HEIF whose brand
|
||||
/// is only among the compatible brands needs the whole <c>ftyp</c> box.
|
||||
/// </summary>
|
||||
public const int HeaderLength = 32;
|
||||
|
||||
/// <summary>The format the bytes start with, or <see cref="ImageFormat.Unknown"/>.</summary>
|
||||
@@ -72,6 +75,13 @@ public static class ImageFormatSniffer
|
||||
{
|
||||
return ImageFormat.Heif;
|
||||
}
|
||||
|
||||
// Every file the HEIF decoder takes (mif2, MiHE, or a HEIF brand among the compatible ones) is a HEIF:
|
||||
// the decoder is chosen from this answer, so a narrower list would leave such a HEIC without a picture.
|
||||
if (Heif.HeifDecoder.Looks(header))
|
||||
{
|
||||
return ImageFormat.Heif;
|
||||
}
|
||||
}
|
||||
|
||||
return ImageFormat.Unknown;
|
||||
|
||||
@@ -10,8 +10,10 @@ namespace Febe.Core.Codecs.Images;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Strictness: a file whose entropy-coded data ends before the last MCU of a scan is damaged
|
||||
/// (<see cref="ImageDecodeException"/>), as is a Huffman code the table does not have; a missing EOI after complete
|
||||
/// scans, bytes after EOI and stray restart markers are accepted. Hierarchical files (SOF5-7, SOF13-15) are refused
|
||||
/// (<see cref="ImageDecodeException"/>), as is a Huffman code the table does not have, and a file that ends before its
|
||||
/// EOI is incomplete even after complete scans (spec §3: a progressive file cut between two scans is refused, not shown
|
||||
/// at a lower quality); <see cref="Identify"/> still reads the size of such a file. Bytes after EOI and stray restart
|
||||
/// markers are accepted. Hierarchical files (SOF5-7, SOF13-15) are refused
|
||||
/// with <see cref="ImageFormatNotSupportedException"/>.
|
||||
/// </remarks>
|
||||
public static class JpegDecoder
|
||||
|
||||
@@ -288,6 +288,13 @@ internal sealed partial class JpegFile : IDisposable
|
||||
return;
|
||||
}
|
||||
|
||||
// Spec §3, §8.4: a JPEG that ends before its end marker is incomplete, even when its scans so far are complete
|
||||
// (a progressive file cut between two scans would otherwise give a picture of lower quality).
|
||||
if (!sawEoi)
|
||||
{
|
||||
throw new ImageDecodeException("JPEG troncato: manca il marcatore di fine (EOI).");
|
||||
}
|
||||
|
||||
if (_scanCount == 0)
|
||||
{
|
||||
throw new ImageDecodeException("JPEG senza dati d'immagine.");
|
||||
|
||||
@@ -48,6 +48,7 @@ public static class PngDecoder
|
||||
{
|
||||
limits ??= ImageLimits.Default;
|
||||
var file = Parse(data, limits, readMetadata: false);
|
||||
RequireEnd(file);
|
||||
return DecodePixels(data, file, limits, pooled);
|
||||
}
|
||||
|
||||
@@ -56,13 +57,27 @@ public static class PngDecoder
|
||||
{
|
||||
limits ??= ImageLimits.Default;
|
||||
var file = Parse(data, limits, readMetadata: true);
|
||||
RequireEnd(file);
|
||||
var image = DecodePixels(data, file, limits, pooled);
|
||||
info = file.ToInfo();
|
||||
return image;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spec §3, §8.4: a PNG that ends before its end marker is incomplete, even when its image data is complete, and is
|
||||
/// not decoded; <see cref="Identify"/> still reads its size.
|
||||
/// </summary>
|
||||
private static void RequireEnd(PngFile file)
|
||||
{
|
||||
if (!file.SeenEnd)
|
||||
{
|
||||
throw new ImageDecodeException("PNG troncato: manca il blocco di fine (IEND).");
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class PngFile
|
||||
{
|
||||
public bool SeenEnd;
|
||||
public int Width;
|
||||
public int Height;
|
||||
public int BitDepth;
|
||||
@@ -129,6 +144,7 @@ public static class PngDecoder
|
||||
var seenPalette = false;
|
||||
var seenTransparency = false;
|
||||
var idatState = 0; // 0 none yet, 1 inside the IDAT run, 2 after it
|
||||
var seenEnd = false;
|
||||
var metadataBudget = limits.MaxMetadataBytes;
|
||||
var pos = 8;
|
||||
while (pos < data.Length)
|
||||
@@ -227,6 +243,7 @@ public static class PngDecoder
|
||||
break;
|
||||
|
||||
case "IEND":
|
||||
seenEnd = true;
|
||||
pos = data.Length;
|
||||
break;
|
||||
|
||||
@@ -275,6 +292,7 @@ public static class PngDecoder
|
||||
throw new ImageDecodeException("PNG senza dati dell'immagine (IDAT).");
|
||||
}
|
||||
|
||||
file.SeenEnd = seenEnd;
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user