-
Notifications
You must be signed in to change notification settings - Fork 245
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
fix(dotnet): crash when TEMP contains certain unicode characters #1913
Merged
Conversation
This file contains 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
In certain environments, the temporary directory path may contain unicode characters. If those are not properly encoded as UTF-8 when sent to the `@jsii/kernel` process, a failure will occur when trying to access such paths. This change contains fixes for two possible sources of problems in such situations: 1. In `@jsii/runtime`, the `SyncStdio` class was a little too eager in turning it's `Buffer` to UTF-8 strings, as it could have only a part of a multi-byte character sequence (the conversion would then fail or result in corruption). Instead, it now looks for `\n` directly on the `Buffer`, and only performs string conversion once one has been found. 2. In the .NET Runtime, the `NodeProcess` class would spawn using the `System.Diagnostic.Process` class without specifying input and output encodings, which by default are the `System.Console` encoding. If that happens to not be `UTF-8`, the result could be unreliable. Instead, the encodings are now forced to `System.Text.Encoding.UTF8` for all three pipes of the child process (`Input`, `Output` and `Error`). Reproducing the conditions for the failure reported in #7456 is somewhat difficult, especially in the context of CI/CD. This makes it difficult to validate those fixes actually deliver on their promises. Fixes #7456
RomainMuller
force-pushed
the
rmuller/path-encoding-weirdness
branch
from
August 18, 2020 10:59
d1f2a9f
to
c5b5e26
Compare
MrArnoldPalmer
approved these changes
Aug 18, 2020
Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it! |
Merging (with squash)... |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
In certain environments, the temporary directory path may contain
unicode characters. If those are not properly encoded as UTF-8 when sent
to the
@jsii/kernel
process, a failure will occur when trying toaccess such paths.
This change contains fixes for two possible sources of problems in such
situations:
@jsii/runtime
, theSyncStdio
class was a little too eager inturning it's
Buffer
to UTF-8 strings, as it could have only a partof a multi-byte character sequence (the conversion would then fail
or result in corruption). Instead, it now looks for
\n
directly onthe
Buffer
, and only performs string conversion once one has beenfound.
NodeProcess
class would spawn using theSystem.Diagnostic.Process
class without specifying input and outputencodings, which by default are the
System.Console
encoding. Ifthat happens to not be
UTF-8
, the result could be unreliable.Instead, the encodings are now forced to
System.Text.Encoding.UTF8
for all three pipes of the child process (
Input
,Output
andError
).Reproducing the conditions for the failure reported in aws/aws-cdk#7456 is
somewhat difficult, especially in the context of CI/CD. This makes it difficult
to validate those fixes actually deliver on their promises.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.