fix(dotnet): crash when TEMP contains certain unicode characters #1913
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.