Repository navigation
fix(datamatrix): return an error instead of panicking past 144x144 capacity - #108
Closed
kihyun1998 wants to merge 1 commit into
Closed
kihyun1998 wants to merge 1 commit into
kihyun1998 wants to merge 1 commit into
Conversation
…pacity EncoderContext::updateSymbolInfo and updateSymbolInfoWithLength unwrapped the symbol lookup, so encoding data that does not fit the largest symbol (or the MaxSize hint) panicked. Both now return Result<()> and propagate the lookup's IllegalArgumentException, matching ZXing's IllegalArgumentException and the compact (minimal encoder) path. Fixes rxing-core#106 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #106
Summary
Every caller (
ascii/base256/c40/edifact/x12encoders,high_level_encoder) already returnsResult<()>, so they just add?. The error is the lookup's ownIllegalArgumentException, the same as ZXing (SymbolInfo.lookupthrowsIllegalArgumentException) and as theDataMatrixCompactpath already returns today.Evidence
tests/github_issues.rs::issue_106_datamatrix_oversize, at the boundaries from the issue:src/datamatrix/encoder/encoder_context.rs:172:22After: passes
Also checked against the fix (no panic anywhere, all
IllegalArgumentException):FORCE_RECTANGLEwith 300 chars,MaxSize10x10 with 100 chars, 4000-char inputs.cargo fmt --check, and the CI commands (check,build,testwith and without default features, workspace, release) all pass.Merge Danger
Door: two-way until released
EncoderContextis publicly re-exported fromdatamatrix::encoder, so both methods change signature (()->Result<()>). An external caller that ignores the return value still compiles, with anunused_must_usewarning; one that binds the()result would not. If you'd rather keep the old signatures for 0.9.4, I can add fallible variants instead.Blast Radius: DataMatrix encoding
Only the oversize path changes behaviour (panic ->
Err); inputs that fit encode as before.🤖 Generated with Claude Code