Escape one character trimmed date formats - #1858
Merged
Merged
Conversation
Formats ending in an upper case fraction get a second scrubber built for the
trimmed format, but a one character format string is a standard format specifier
rather than the custom one it was written as. So ScrubInlineDateTimes("s.F")
trimmed to "s", the sortable pattern, and scrubbed every full sortable date-time
in the output, while "H.F" trimmed to "H" and threw "Invalid format: H" at
registration despite passing the up-front validation.
The trimmed format is now escaped with `%` when a single character is left, and
no second scrubber is built when nothing is left at all.
This was referenced Aug 26, 2026
This was referenced Aug 28, 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.
DateMatchers.BuildForFormatsbuilds a second scrubber for the trimmed format when a format ends in an upper case fraction, since those render as empty when the fraction is zero.TryGetFormatWithUpperMillisecondsTrimmedhanded back the trimmed string raw, and a one character format string is read as a standard format specifier rather than the custom one it was written as:ScrubInlineDateTimes("s.F")trimmed to"s", which expands to the culture's sortable pattern — so the second scrubber scrubbed every full sortable date-time in the output.ScrubInlineDateTimes("H.F")trimmed to"H", which is not a standard specifier at all —Invalid format: Hat registration, after the format had already passed the up-front validation.Now
%escapes the trimmed format when one character is left, which is what forces it to be read as a custom specifier, and no second scrubber is built when trimming leaves nothing (".F").Tests in the new
TrimmedFractionTestscover all three cases; all three fail onmain.ApplyScrubbersTests(114),Verify.Tests(1299) andStaticSettingsTestspass.Unrelated observation while in here: the trim only recognises
.Fthrough.FFFF, so.FFFFFthrough.FFFFFFFnever get a trimmed scrubber. Left alone sinceTryParseExacttreats the fraction (and its period) as optional anyway, which makes the second scrubber look redundant rather than missing — worth a separate look at whether it earns its keep at all.