-
Notifications
You must be signed in to change notification settings - Fork 1.2k
JSONDecoder.readString(): throw on invalid UTF-8 #4675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
String(decoding:as:), which previously used by JSONDecoder.readString() to make string from JSON bytes, would silently repair invalid UTF-8 sequence and not throw a error. This commit uses String(bytes:encoding:) instead, which will fail on invalid UTF-8 seqence. This matches the behavior of Darwin Foundation. (Some examples of invalid UTF-8: http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt)
@swift-ci test |
@swift-ci test Windows |
@swift-ci test |
@MaxDesiatov Why is macOS test failing? Shall I care about that?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look fine.
Something seems wrong infrastructurally in the CI:
dyld: Library not loaded: @rpath/lib_SwiftSyntaxMacros.dylib
Referenced from: /Users/ec2-user/jenkins/workspace/swift-corelibs-foundation-PR-macOS/branch-main/build/Ninja-ReleaseAssert/toolchain-macosx-x86_64/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
Reason: image not found
@shahmishal Can you help out with the build failiure? |
This comment was marked as duplicate.
This comment was marked as duplicate.
4 similar comments
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
@swift-ci test macOS |
@swift-ci test macOS |
Thank you! Sorry for the long delay while we figured out the CI issues. |
String(decoding:as:), which previously used by
JSONDecoder.readString() to make string from JSON bytes, would silently repair invalid UTF-8 sequence and not throw a error.
This commit uses String(bytes:encoding:) instead,
which will fail on invalid UTF-8 seqence.
This matches the behavior of Darwin Foundation.
(Some examples of invalid UTF-8: http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt)