Repository navigation
fix(isoDate): pad a bare-hour timeshift with a colon, not just zeros - #3143
Merged
Merged
Conversation
internals.isoDate() pads a bare-hour UTC timeshift (e.g. "+04") before handing the string to Date() by appending '00' directly, producing "...+0400" instead of the ISO 8601 extended-format "...+04:00". Node's own Date parser tolerates the malformed form, which is why this went unnoticed, but it breaks stricter parsers (Safari) since ISO 8601 doesn't allow mixing basic-format offsets into an otherwise extended-format string. Flagged by a reviewer on hapijs#2421 (the PR that introduced this line) but never addressed after merge; tracked since as hapijs#2434. Also drops the leading `.*` in the trigger regex, per the same review thread - matching doesn't require anchoring at the string start, so it was redundant. Since Node's Date constructor doesn't distinguish "+0700" from "+07:00", a test asserting on Joi's converted output wouldn't catch a regression here. The new test instead spies on the Date constructor to assert the actual string produced. Fixes hapijs#2434.
There was a problem hiding this comment.
Pull request overview
This pull request fixes string.isoDate() coercion so that ISO 8601 datetimes with a bare-hour UTC offset (e.g. +07) are normalized to the extended offset form (+07:00) before being parsed by Date(), avoiding invalid mixed-format offsets that break stricter parsers (notably Safari).
Changes:
- Update
internals.isoDate()normalization to append:00(extended) instead of00(basic) when padding a bare-hour timeshift. - Simplify the trigger regex by removing the redundant leading
.*. - Add a regression test that spies on the argument passed into
Date()to ensure the colonized offset is used.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/types/string.js | Fixes bare-hour offset padding to use +HH:00 (extended format) before calling new Date(value). |
| test/types/string.js | Adds a regression test that temporarily replaces global.Date to assert the exact string passed to Date(). |
π‘ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Collaborator
|
Thanks a lot. I'm also adding the security label, as it incidentally covers a vulnerability that was recently reported. |
Marsup
added a commit
that referenced
this pull request
Sep 2, 2026
(cherry picked from commit cc81a74)
Marsup
added a commit
that referenced
this pull request
Sep 2, 2026
chore: add regression test for #3143
Marsup
added a commit
that referenced
this pull request
Sep 2, 2026
meta-codesync Bot
pushed a commit
to meta/memlab
that referenced
this pull request
Sep 21, 2026
Summary: Bumps [[ https://github.com/hapijs/joi | joi ]] from 17.13.4 to 17.13.7 in the memlab `website` package. The range picks up two prototype-pollution fixes plus an ISO date parsing fix. == Notable changes == - **17.13.7** β `fix(isoDate)`: pad a bare-hour timeshift with a colon, not just zeros ([[ hapijs/joi#3143 | #3143 ]], backported in [[ hapijs/joi#3145 | #3145 ]]) - **17.13.6** β prevent `messages` prototype injection ([[ hapijs/joi#3139 | #3139 ]]) - **17.13.5** β prevent `__proto__` on renames ([[ hapijs/joi#3135 | #3135 ]]) == Commits == - [[ hapijs/joi@ed9d7cd | ed9d7cd ]] 17.13.7 - [[ hapijs/joi@f2729f7 | f2729f7 ]] Merge pull request [[ hapijs/joi#3145 | #3145 ]] from hapijs/backport/isodate-timeshift-v17 - [[ hapijs/joi@c43fc96 | c43fc96 ]] chore: add regression test for [[ hapijs/joi#3143 | #3143 ]] - [[ hapijs/joi@115e7b5 | 115e7b5 ]] fix(isoDate): pad a bare-hour timeshift with a colon, not just zeros - [[ hapijs/joi@850be1e | 850be1e ]] 17.13.6 - [[ hapijs/joi@9faeecc | 9faeecc ]] Merge pull request [[ hapijs/joi#3139 | #3139 ]] from hapijs/chore/backport-messages-proto - [[ hapijs/joi@8d0b808 | 8d0b808 ]] fix: prevent messages proto injection - [[ hapijs/joi@566e73f | 566e73f ]] 17.13.5 - [[ hapijs/joi@3f3907c | 3f3907c ]] Merge pull request [[ hapijs/joi#3135 | #3135 ]] from hapijs/chore/backport-rename-proto - [[ hapijs/joi@172ecec | 172ecec ]] fix: prevent proto on renames [[ hapijs/joi@v17.13.4...v17.13.7 | Full compare view: v17.13.4...v17.13.7 ]] Pull Request resolved: #150 Differential Revision: D119235919 Pulled By: JacksonGL fbshipit-source-id: 8b1427cfa5b65eab42a93ad713856feb7c57e1cc
daggerstuff
added a commit
to daggerstuff/pixelated
that referenced
this pull request
Sep 24, 2026
* chore(deps): bump joi 17.13.4 -> 17.13.8 Replaces the production-patches bump from the deleted dependabot branch (#6051): joi 17.13.5-17.13.8 carry the messages proto-injection guard (hapijs/joi#3151) and the isoDate timeshift padding fix (hapijs/joi#3143). Co-Authored-By: Claude Code <noreply@anthropic.com> * fix(deps): bump joi override pin to 17.13.8 The pnpm-workspace overrides pin joi: 17.13.4 was superseding the manifest ^17.13.8 bump from the major-updates merge (#6053), making the new version dead-letter and breaking the frozen lockfile check. Co-Authored-By: Claude Code <noreply@anthropic.com> * fix(deps): keep joi@17.13.4 resolvable for transitive pins px-cli's install still resolves joi@17.13.4 (some tooling pins the exact patch). Re-add its package + snapshot entries alongside 17.13.8. Co-Authored-By: Claude Code <noreply@anthropic.com> --------- Co-authored-by: Dagger <dagger@users.noreply.github.com> Co-authored-by: Claude Code <noreply@anthropic.com>
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
benjaminandrew386-boop
approved these changes
Nov 1, 2026
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 #2434.
What
`internals.isoDate()` (`lib/types/string.js`) pads a bare-hour UTC timeshift like `+04` before handing the string to `Date()`:
```js
if (/.T.[+-]\d\d$/.test(value)) { // Add missing trailing zeros to timeshift
value += '00';
}
```
That produces `...+0400` β ISO 8601 basic-format offset β glued onto an otherwise extended-format string (`YYYY-MM-DDTHH:mm:ss`). ISO 8601 doesn't allow mixing the two; the correct extended-format offset is `...+04:00`.
This was flagged by @kanongil in review on #2421 (the PR that introduced the line): "You need to add the
:as well to make it a proper extended iso date string. As it is, it breaks in Safari." The PR was merged before the fix landed, and #2434 was opened to track it but never addressed.Also drops the leading
.*in the trigger regex, per the same review thread (.test()doesn't need start-anchoring, so it was redundant).Fix
```js
if (/T.*[+-]\d\d$/.test(value)) { // Add missing separator and trailing zeros to timeshift
value += ':00';
}
```
Testing
Node's own `Date` constructor parses `+0700` and `+07:00` identically, so a test asserting on Joi's converted output (`.toISOString()`) can't distinguish the bug from the fix β I confirmed this empirically before writing the test. Instead, the new test spies on the global `Date` constructor to assert the exact string Joi passes to it.