Skip to content

Commit

Permalink
[tools] Fix quoting quotes in StringUtils.QuoteForProcess. (#11949)
Browse files Browse the repository at this point in the history
* [tools] Fix quoting quotes in StringUtils.QuoteForProcess.

Previously quoting a string with a quote:

    a"b

would result in:

    "a\"""b"

There are way too many quotes there.

We'll now get:

    "a\"b"

which is correct.

* Add unit test.
  • Loading branch information
rolfbjarne authored Jun 17, 2021
1 parent 242b889 commit 0c1c1a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 12 additions & 0 deletions tests/mtouch/StringUtilsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,17 @@ public void ParseVersion ()
v = StringUtils.ParseVersion ("10.13.2");
Assert.That (v.ToString (), Is.EqualTo ("10.13.2"), "10.13.2");
}

[Test]
public void QuoteForProcess ()
{
Assert.That (StringUtils.QuoteForProcess ("a"), Is.EqualTo ("a"), "normal");
Assert.That (StringUtils.QuoteForProcess ("😁"), Is.EqualTo ("😁"), "😁");
Assert.That (StringUtils.QuoteForProcess ("b b"), Is.EqualTo ("\"b b\""), "space");
Assert.That (StringUtils.QuoteForProcess ("'"), Is.EqualTo ("\"'\""), "single quote");
Assert.That (StringUtils.QuoteForProcess ("\\"), Is.EqualTo ("\"\\\\\""), "backslash");
Assert.That (StringUtils.QuoteForProcess ("\""), Is.EqualTo ("\"\\\"\""), "double quote");
Assert.That (StringUtils.QuoteForProcess (@"C:\double "" quote\single ' quote\space here\"), Is.EqualTo (@"""C:\\double \"" quote\\single ' quote\\space here\\"""), "windows path");
}
}
}
1 change: 0 additions & 1 deletion tools/common/StringUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public static string QuoteForProcess (string f)
foreach (var c in f) {
if (c == '"') {
s.Append ('\\');
s.Append (c).Append (c);
} else if (c == '\\') {
s.Append (c);
}
Expand Down

8 comments on commit 0c1c1a7

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

API Diff (from PR only) (no change)
Generator Diff (no change)

Packages generated

View packages

Test results

2 tests failed, 219 tests passed.

Failed tests

  • link all/Mac Catalyst/Debug: TimedOut (Execution timed out after 1200 seconds.
    No test log file was produced)
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 5.0): Failed

Pipeline on Agent XAMBOT-1028.BigSur'
[tools] Fix quoting quotes in StringUtils.QuoteForProcess. (#11949)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on VSTS: device tests tvOS 🔥

Not enough free space in the host.

Pipeline on Agent
[tools] Fix quoting quotes in StringUtils.QuoteForProcess. (#11949)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Tests were not ran (VSTS: device tests iOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[tools] Fix quoting quotes in StringUtils.QuoteForProcess. (#11949)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Tests were not ran (VSTS: device tests tvOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[tools] Fix quoting quotes in StringUtils.QuoteForProcess. (#11949)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Tests passed on macOS Mac Catalina (10.15) ✅

Tests passed

All tests on macOS X Mac Catalina (10.15) passed.

Pipeline on Agent
[tools] Fix quoting quotes in StringUtils.QuoteForProcess. (#11949)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Tests passed on macOS Mac Mojave (10.14) ✅

Tests passed

All tests on macOS X Mac Mojave (10.14) passed.

Pipeline on Agent
[tools] Fix quoting quotes in StringUtils.QuoteForProcess. (#11949)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Tests passed on macOS Mac High Sierra (10.13) ✅

Tests passed

All tests on macOS X Mac High Sierra (10.13) passed.

Pipeline on Agent
[tools] Fix quoting quotes in StringUtils.QuoteForProcess. (#11949)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Tests were not ran (VSTS: device tests iOS32b). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[tools] Fix quoting quotes in StringUtils.QuoteForProcess. (#11949)

Please sign in to comment.