Repository navigation
feat: implement JavaScript string escaping for environment variables and add unit tests - #1059
Merged
Merged
Conversation
…and add unit tests
There was a problem hiding this comment.
Pull request overview
Implements JavaScript string escaping when emitting environment variables into uno-config.js, and adds unit tests for the escaping behavior.
Changes:
- Escape environment variable values during config generation (
GenerateConfig). - Introduce
EscapeJsStringhelper to perform escaping. - Add MSTest coverage validating escaping for quotes and backslashes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/Uno.Wasm.Bootstrap/ShellTask.cs |
Escapes emitted env-var values in generated JS config and adds an escaping helper. |
src/Uno.Wasm.Bootstrap.UnitTests/Given_ShellTask_EnvironmentVariableEscaping.cs |
Adds unit tests covering the escaping helper’s current behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/Uno.Wasm.Bootstrap/ShellTask.cs:605
- The environment variable name is interpolated into a JS string literal without escaping. If a
MonoEnvironmentitem spec ever contains\or"(or other special chars), the generateduno-config.jswill be syntactically invalid or could be subject to code injection. Consider escapingnamewith the same JS-string escaping routine (or emitting both name/value using a JSON string literal).
config.AppendLine($"config.environmentVariables = config.environmentVariables || {{}};");
void AddEnvironmentVariable(string name, string value) => config.AppendLine($"config.environmentVariables[\"{name}\"] = \"{EscapeJsString(value)}\";");
if (MonoEnvironment != null)
{
foreach (var env in MonoEnvironment)
{
AddEnvironmentVariable(env.ItemSpec, env.GetMetadata("Value"));
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…e ShellTask usage
jeromelaban
enabled auto-merge
April 8, 2026 20:29
jeromelaban
approved these changes
Apr 8, 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.
No description provided.