Repository navigation
Write credential JSON with relaxed escaping so Windows' blob cap counts real bytes [patch] - #203
Merged
Merged
Conversation
…ts real bytes System.Text.Json's default encoder wrote '+', '<', '>', '&', '\'' and every non-ASCII character as a six-byte \uXXXX escape, so a 2400-character base64 token serialized to 2662 bytes and Windows Credential Manager rejected it against its 2560-byte cap. Serialize with UnsafeRelaxedJsonEscaping instead; the payload is never embedded in HTML or script, and blobs written with the old escapes still deserialize. Fixes #175 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW3kaZKRNvfNtvM4CX6
|
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 #175
What was wrong
CredentialSerialization.BuildOptionsused System.Text.Json's defaultJavaScriptEncoder. That encoder writes+,<,>,&,'and every non-ASCII character as a six-byte\uXXXX. A 2400-character base64 token came out at 2662 bytes, soWindowsCredentialStore.Saverejected it against the 2560-byte cap, while Linux and macOS stored the same credential.Change
BuildOptionssetsEncoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping. The payload is never embedded in HTML or script, so HTML-safe escaping does nothing for it. The reader accepts both forms, so credentials already stored still load.System.Text.Encodings.Web10.0.14 reference, whichKTSU0006requires for direct use of a transitive package. It is the versionSystem.Text.Json10.0.14 already brings in.Tests
New
SerializationEscapingTests:SerializeandSerializeToStringwrite+,<>&', Cyrillic and CJK as raw UTF-8, with no\u.+serializes to no more than its own length plus the envelope.DeserializeandDeserializeFromString.Without the fix, the first three fail and the backward-compatibility test passes. The full suite on net10.0 (Linux): 89 tests, 84 passed, 0 failed, 5 skipped. The skips are the existing native-store tests that need libsecret or Windows.
Generated by Claude Code