Exception while brotliDecode in decode.ts #468

Closed
opened 2026-01-29 20:44:23 +00:00 by claunia · 5 comments
Owner

Originally created by @mcdis on GitHub (Jul 10, 2023).

Error: Exuberant nibble
at decodeMetaBlockLength (decode.ts:209:1)

Origin data (hex string) (357 bytes):

0x03f801008cd3153784b7c19e6d2a4debb1974e6b87d934d756c82ba821e44b41c91eee1db0dfbdfb63818cc6e680eed516c828d010b23147734b3f1b0827f106a03b6ade05b5f46c170029ac071624cd9109e4965a5c612ecb28e41bad0d12f49ec3a0070b9f51a6c43ff929476747db7d9d871d033ab6c6cc215e0b8642ee6035c9c86f57cc28eeb2407015a2ef617d8e8f5a16fa676be45cd9d2fc7479cc06afa4eea409c1d5efd39dc02d8601cdbf3c9ec54808b6749438acb9be48639cf601491a196235ea5ce7b354998493702e93087c916a4d0533ca503b58af4aa04b6a164da97f72cd908822b925d65cc86a6b40e65168d083b6c45efc159a0cf95f9bbc41914263a363c8705b0fb41d3c96acefe752195afba4ab6126d4c05f7b2fb1bd50529a9c0aabf4ee9e2de2167bf6cd4b88d14db6db640fc70c5849b5a663f2d01ac8bdf46f0b057d43ffb13df75b54892e49294a04ee34f7bd8ab471782e796af0d19c

Compressed using BrotliSteam / C#. Decompressing successfully. Uncompressed size: 1009

        await using var stream = new BrotliStream(input, CompressionMode.Decompress);
        await stream.CopyToAsync(output);
        await stream.FlushAsync();
Originally created by @mcdis on GitHub (Jul 10, 2023). Error: Exuberant nibble at decodeMetaBlockLength (decode.ts:209:1) Origin data (hex string) (357 bytes): ``` 0x03f801008cd3153784b7c19e6d2a4debb1974e6b87d934d756c82ba821e44b41c91eee1db0dfbdfb63818cc6e680eed516c828d010b23147734b3f1b0827f106a03b6ade05b5f46c170029ac071624cd9109e4965a5c612ecb28e41bad0d12f49ec3a0070b9f51a6c43ff929476747db7d9d871d033ab6c6cc215e0b8642ee6035c9c86f57cc28eeb2407015a2ef617d8e8f5a16fa676be45cd9d2fc7479cc06afa4eea409c1d5efd39dc02d8601cdbf3c9ec54808b6749438acb9be48639cf601491a196235ea5ce7b354998493702e93087c916a4d0533ca503b58af4aa04b6a164da97f72cd908822b925d65cc86a6b40e65168d083b6c45efc159a0cf95f9bbc41914263a363c8705b0fb41d3c96acefe752195afba4ab6126d4c05f7b2fb1bd50529a9c0aabf4ee9e2de2167bf6cd4b88d14db6db640fc70c5849b5a663f2d01ac8bdf46f0b057d43ffb13df75b54892e49294a04ee34f7bd8ab471782e796af0d19c ``` Compressed using BrotliSteam / C#. Decompressing successfully. Uncompressed size: 1009 ```csharp await using var stream = new BrotliStream(input, CompressionMode.Decompress); await stream.CopyToAsync(output); await stream.FlushAsync(); ```
Author
Owner

@eustas commented on GitHub (Jul 10, 2023):

Tried to turn "origin data" to brotli file and got corrupted files both interpreting this string LE and BE.
Could you attach compressed file either base64 encoded or as a file (drag-n-drop to comment). Thanks.

@eustas commented on GitHub (Jul 10, 2023): Tried to turn "origin data" to brotli file and got corrupted files both interpreting this string LE and BE. Could you attach compressed file either base64 encoded or as a file (drag-n-drop to comment). Thanks.
Author
Owner

@mcdis commented on GitHub (Jul 10, 2023):

welcome.txt
welcome_br2.txt
welcome_br2_restored.txt

welcome.txt - original
welcome_br2.txt - brotli compressed
welcome_br2_restored.txt - restored version after decompress compressed

It's very strange, but in C# the last dot symbol is lost when unpacking, but there are no errors

encode:

    await using var input = File.OpenRead(src);
    await using (var output = File.OpenWrite(dst))
    {    
        await using var stream = new BrotliStream(output, CompressionLevel.SmallestSize);
        await input.CopyToAsync(stream);
        await input.FlushAsync();
        await stream.FlushAsync();
    }

decode:

    await using var input = File.OpenRead(src);
    await using (var output = File.OpenWrite(dst))
    {
        await using var stream = new BrotliStream(input, CompressionMode.Decompress);
        await stream.CopyToAsync(output);
        await stream.FlushAsync();
        await output.FlushAsync();
    }
@mcdis commented on GitHub (Jul 10, 2023): [welcome.txt](https://github.com/google/brotli/files/12002889/welcome.txt) [welcome_br2.txt](https://github.com/google/brotli/files/12002909/welcome_br2.txt) [welcome_br2_restored.txt](https://github.com/google/brotli/files/12002915/welcome_br2_restored.txt) `welcome.txt` - original `welcome_br2.txt` - brotli compressed `welcome_br2_restored.txt` - restored version after decompress compressed It's very strange, but in C# the last dot symbol is lost when unpacking, but there are no errors encode: ```csharp await using var input = File.OpenRead(src); await using (var output = File.OpenWrite(dst)) { await using var stream = new BrotliStream(output, CompressionLevel.SmallestSize); await input.CopyToAsync(stream); await input.FlushAsync(); await stream.FlushAsync(); } ``` decode: ```csharp await using var input = File.OpenRead(src); await using (var output = File.OpenWrite(dst)) { await using var stream = new BrotliStream(input, CompressionMode.Decompress); await stream.CopyToAsync(output); await stream.FlushAsync(); await output.FlushAsync(); } ```
Author
Owner

@mcdis commented on GitHub (Jul 10, 2023):

C# implementation uses quality = 11, window = 22 for Brotli

@mcdis commented on GitHub (Jul 10, 2023): C# implementation uses quality = 11, window = 22 for Brotli
Author
Owner

@eustas commented on GitHub (Jul 10, 2023):

CLI tool confirms that welcome_br2.txt is truncated. Not sure what is C# brotli library (its source code is not in this repository). Don't know what are C# syntax / semantics as well, but I'd try the following snippet for encoding:

await using var input = File.OpenRead(src);
await using var output = File.OpenWrite(dst);
using (var stream = new BrotliStream(output, CompressionLevel.SmallestSize)) {    
   await input.CopyToAsync(stream);
}  // I expect that `stream` is flushed and disposed at this point
await output.FlushAsync();
@eustas commented on GitHub (Jul 10, 2023): CLI tool confirms that `welcome_br2.txt` is truncated. Not sure what is C# brotli library (its source code is not in this repository). Don't know what are C# syntax / semantics as well, but I'd try the following snippet for encoding: ``` await using var input = File.OpenRead(src); await using var output = File.OpenWrite(dst); using (var stream = new BrotliStream(output, CompressionLevel.SmallestSize)) { await input.CopyToAsync(stream); } // I expect that `stream` is flushed and disposed at this point await output.FlushAsync(); ```
Author
Owner

@MichalPetryka commented on GitHub (Jul 31, 2023):

Not sure what is C# brotli library

C# has brotli built-in into the base framework, it uses the latest Brotli release for it.

@MichalPetryka commented on GitHub (Jul 31, 2023): > Not sure what is C# brotli library C# has brotli built-in into the base framework, it uses the latest Brotli release for it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#468