fix(he): guard scale ceilings in he-IL, hbo-IL#356
Merged
Conversation
Both emit "undefined" past their scale vocabulary. Per-form ceilings differ: - Cardinal/currency: SCALE reaches 10^18, so ceiling 10^21 (derived from SCALE.length). - Ordinal: past 10^6 the millions multiplier is built with buildScaleSegment (0-999), so it overflows to "undefined מיליונים" at 10^9 (same shape as the Spanish ordinal). Guard at 10^9. Entry-point pattern: MAX_CARDINAL/MAX_ORDINAL up front, short-circuit in toCardinal/toOrdinal/toCurrency after parsing. NO decimal guard — Hebrew reads the fraction digit-by-digit (40-digit decimal still converts). hbo-IL (Biblical Hebrew) shares he-IL's structure. Verified per variant (well-formed or RangeError; integer/ordinal boundary; decimals stay clean); full suite green (269). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds explicit scale-ceiling guards for Modern Hebrew (he-IL) and Biblical Hebrew (hbo-IL) so inputs beyond each locale’s expressible magnitude throw a consistent RangeError (via tooLargeError) instead of producing malformed output (e.g., "undefined" segments). This aligns these language modules with the ongoing “fix-then-gate” hardening pattern across src/.
Changes:
- Introduces derived magnitude limits (
MAX_CARDINALfromSCALE.length, and a stricterMAX_ORDINAL) in both Hebrew variants. - Enforces the ceilings at the public entry points:
toCardinal,toOrdinal, andtoCurrency. - Uses the shared
tooLargeError(maxExponent)helper for a uniform RangeError message.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/he-IL.js |
Adds cardinal/currency (10^21) and ordinal (10^9) ceilings and throws tooLargeError(...) at public entry points. |
src/hbo-IL.js |
Mirrors the same ceiling constants and entry-point guards for Biblical Hebrew. |
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.
Eighth in the fix-then-gate series. Modern + Biblical Hebrew.
What fuzzing found
Both emit
"undefined"past their scale vocabulary, with per-form ceilings:SCALEreaches 10¹⁸ (7 entries)buildScaleSegment(0–999) →"undefined מיליונים"at 10⁹, same shape as the Spanish ordinalFix
Entry-point pattern:
MAX_CARDINAL(derived fromSCALE.length) +MAX_ORDINAL(10⁹) up front, short-circuit intoCardinal/toOrdinal/toCurrencyafter parsing. No decimal guard — Hebrew reads the fraction digit-by-digit (a 40-digit decimal still converts).hbo-IL(Biblical Hebrew) shareshe-IL's structure — and is also the corpus's one valid-BCP-47-but-not-in-CLDR tag.Verification
Per variant: well-formed string or
RangeErroracross±10³⁰; integer/ordinal boundary (10²¹/10⁹); long decimals confirmed still clean. Existing fixtures green, lint clean, 269 tests.🤖 Generated with Claude Code