Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: do not skip last char when decompressing text where the last chars are uncompressed #360

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

andipaetzold
Copy link
Owner

@andipaetzold andipaetzold commented Feb 17, 2025

Compressed text is not 100% compressed. It's a mix of compressed and uncompressed text. The compression mode switches between parsing compressed and uncompressed bytes using a 0x00 byte.

There was a bug where the last character was accidentally skipped when it was uncompressed. The root cause was that the number of remaining characters was not calculated correctly and it was assumed that the one char shorter than it actually was.

With this PR, the decompress code should be easier to read and it is more obvious when the curPos variable is incremented. The performance is slightly worse as we read some bytes twice. But I think we can ignore that aspect here.

@andipaetzold andipaetzold linked an issue Feb 17, 2025 that may be closed by this pull request
Copy link

Size Change: +10 B (+0.02%)

Total Size: 49.3 kB

Filename Size Change
lib/browser/unicodeCompression.js 596 B +5 B (+0.85%)
lib/node/unicodeCompression.js 596 B +5 B (+0.85%)
ℹ️ View Unchanged
Filename Size
lib/browser/array.js 396 B
lib/browser/codec-handler/create.js 272 B
lib/browser/codec-handler/handlers/identity.js 123 B
lib/browser/codec-handler/handlers/jet.js 356 B
lib/browser/codec-handler/handlers/office/agile/EncryptionDescriptor.js 617 B
lib/browser/codec-handler/handlers/office/agile/index.js 767 B
lib/browser/codec-handler/handlers/office/agile/types.js 31 B
lib/browser/codec-handler/handlers/office/CryptoAlgorithm.js 227 B
lib/browser/codec-handler/handlers/office/EncryptionHeader.js 897 B
lib/browser/codec-handler/handlers/office/EncryptionVerifier.js 374 B
lib/browser/codec-handler/handlers/office/HashAlgorithm.js 98 B
lib/browser/codec-handler/handlers/office/index.js 903 B
lib/browser/codec-handler/handlers/office/rc4-cryptoapi.js 679 B
lib/browser/codec-handler/index.js 78 B
lib/browser/codec-handler/types.js 31 B
lib/browser/codec-handler/util.js 175 B
lib/browser/column.js 535 B
lib/browser/crypto/blockDecrypt.js 231 B
lib/browser/crypto/deriveKey.js 370 B
lib/browser/crypto/hash.js 228 B
lib/browser/crypto/index.js 80 B
lib/browser/crypto/rc4.js 478 B
lib/browser/crypto/types.js 31 B
lib/browser/data/bigint.js 83 B
lib/browser/data/binary.js 114 B
lib/browser/data/byte.js 82 B
lib/browser/data/complexOrLong.js 93 B
lib/browser/data/currency.js 493 B
lib/browser/data/datetime.js 181 B
lib/browser/data/datetimextended.js 480 B
lib/browser/data/double.js 81 B
lib/browser/data/float.js 80 B
lib/browser/data/index.js 542 B
lib/browser/data/integer.js 84 B
lib/browser/data/memo.js 606 B
lib/browser/data/numeric.js 522 B
lib/browser/data/ole.js 530 B
lib/browser/data/repid.js 289 B
lib/browser/data/text.js 149 B
lib/browser/data/util.js 351 B
lib/browser/Database.js 1.45 kB
lib/browser/dependencies/iconv-lite/index.js 792 B
lib/browser/environment/index.js 129 B
lib/browser/index.js 74 B
lib/browser/JetFormat/index.js 714 B
lib/browser/JetFormat/Jet12Format.js 129 B
lib/browser/JetFormat/Jet14Format.js 143 B
lib/browser/JetFormat/Jet15Format.js 79 B
lib/browser/JetFormat/Jet16Format.js 79 B
lib/browser/JetFormat/Jet17Format.js 79 B
lib/browser/JetFormat/Jet3Format.js 470 B
lib/browser/JetFormat/Jet4Format.js 476 B
lib/browser/JetFormat/MSISAMFormat.js 132 B
lib/browser/JetFormat/types.js 132 B
lib/browser/MDBReader.js 930 B
lib/browser/PageType.js 381 B
lib/browser/SortOrder.js 136 B
lib/browser/SysObject.js 485 B
lib/browser/Table.js 3.03 kB
lib/browser/types.js 237 B
lib/browser/usage-map.js 681 B
lib/browser/util.js 598 B
lib/node/array.js 396 B
lib/node/codec-handler/create.js 272 B
lib/node/codec-handler/handlers/identity.js 123 B
lib/node/codec-handler/handlers/jet.js 356 B
lib/node/codec-handler/handlers/office/agile/EncryptionDescriptor.js 617 B
lib/node/codec-handler/handlers/office/agile/index.js 767 B
lib/node/codec-handler/handlers/office/agile/types.js 31 B
lib/node/codec-handler/handlers/office/CryptoAlgorithm.js 227 B
lib/node/codec-handler/handlers/office/EncryptionHeader.js 897 B
lib/node/codec-handler/handlers/office/EncryptionVerifier.js 374 B
lib/node/codec-handler/handlers/office/HashAlgorithm.js 98 B
lib/node/codec-handler/handlers/office/index.js 903 B
lib/node/codec-handler/handlers/office/rc4-cryptoapi.js 679 B
lib/node/codec-handler/index.js 78 B
lib/node/codec-handler/types.js 31 B
lib/node/codec-handler/util.js 175 B
lib/node/column.js 535 B
lib/node/crypto/blockDecrypt.js 231 B
lib/node/crypto/deriveKey.js 370 B
lib/node/crypto/hash.js 228 B
lib/node/crypto/index.js 80 B
lib/node/crypto/rc4.js 478 B
lib/node/crypto/types.js 31 B
lib/node/data/bigint.js 83 B
lib/node/data/binary.js 114 B
lib/node/data/byte.js 82 B
lib/node/data/complexOrLong.js 93 B
lib/node/data/currency.js 493 B
lib/node/data/datetime.js 181 B
lib/node/data/datetimextended.js 480 B
lib/node/data/double.js 81 B
lib/node/data/float.js 80 B
lib/node/data/index.js 542 B
lib/node/data/integer.js 84 B
lib/node/data/memo.js 606 B
lib/node/data/numeric.js 522 B
lib/node/data/ole.js 530 B
lib/node/data/repid.js 289 B
lib/node/data/text.js 149 B
lib/node/data/util.js 351 B
lib/node/Database.js 1.45 kB
lib/node/dependencies/iconv-lite/index.js 792 B
lib/node/environment/index.js 70 B
lib/node/index.js 74 B
lib/node/JetFormat/index.js 714 B
lib/node/JetFormat/Jet12Format.js 129 B
lib/node/JetFormat/Jet14Format.js 143 B
lib/node/JetFormat/Jet15Format.js 79 B
lib/node/JetFormat/Jet16Format.js 79 B
lib/node/JetFormat/Jet17Format.js 79 B
lib/node/JetFormat/Jet3Format.js 470 B
lib/node/JetFormat/Jet4Format.js 476 B
lib/node/JetFormat/MSISAMFormat.js 132 B
lib/node/JetFormat/types.js 132 B
lib/node/MDBReader.js 930 B
lib/node/PageType.js 381 B
lib/node/SortOrder.js 136 B
lib/node/SysObject.js 485 B
lib/node/Table.js 3.03 kB
lib/node/types.js 237 B
lib/node/usage-map.js 681 B
lib/node/util.js 598 B

compressed-size-action

@andipaetzold andipaetzold changed the title fix: do not skip last char when decompressing text where the last characters are uncompressed fix: do not skip last char when decompressing text where the last characters are not compressed Feb 17, 2025
@andipaetzold andipaetzold self-assigned this Feb 17, 2025
@andipaetzold andipaetzold changed the title fix: do not skip last char when decompressing text where the last characters are not compressed fix: do not skip last char when decompressing text where the last characters are uncompressed Feb 17, 2025
@andipaetzold andipaetzold marked this pull request as ready for review February 17, 2025 23:19
@andipaetzold andipaetzold changed the title fix: do not skip last char when decompressing text where the last characters are uncompressed fix: do not skip last char when decompressing text where the last chars are uncompressed Feb 17, 2025
@andipaetzold andipaetzold merged commit 30bea44 into main Feb 17, 2025
9 checks passed
@andipaetzold andipaetzold deleted the 358-unable-to-ready-last-character-of-out branch February 17, 2025 23:20
github-actions bot pushed a commit that referenced this pull request Feb 17, 2025
## [3.0.1](v3.0.0...v3.0.1) (2025-02-17)

### Bug Fixes

* do not skip last char when decompressing text where the last characters are uncompressed ([#360](#360)) ([30bea44](30bea44))
Copy link

🎉 This PR is included in version 3.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to ready last ' character of ‘Out’
1 participant