Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/1.7.1'
Browse files Browse the repository at this point in the history
* hotfix/1.7.1:
  (GH-85) Corrected nuget package description
  (GH-83) Corrected paths used inside codecov nuget package
  (GH-84) Properly escape branch names
  (GH-84) Added unit tests for escaping branch uri data
  • Loading branch information
AdmiringWorm committed Aug 2, 2019
2 parents 708d0ae + 1d3a15d commit 91286a2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
20 changes: 20 additions & 0 deletions Source/Codecov.Tests/Url/QueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@ public void Multiple_Repositories_Should_Used_ContiniousIntegrationServer_First(
getQuery.FirstOrDefault(x => x.StartsWith("branch=")).Should().Be("branch=develop");
}

[Fact]
public void Should_Encode_Slashes_In_BranchName()
{
// Given
var queryOptions = Substitute.For<IQueryOptions>();
var continiousIntegrationServer = Substitute.For<IRepository>();
continiousIntegrationServer.Branch.Returns("release/6.0.0");
var versionControlSystem = Substitute.For<IRepository>();
versionControlSystem.Branch.Returns("dev");
var build = Substitute.For<IBuild>();
var yaml = Substitute.For<IYaml>();
var query = new Query(queryOptions, new[] { continiousIntegrationServer, versionControlSystem }, build, yaml);

// When
var getQuery = query.GetQuery.Split('&');

// Then
getQuery.Should().Contain("branch=release%2F6.0.0");
}

[Fact]
public void Should_Double_Encode_Pluss_Signs()
{
Expand Down
14 changes: 9 additions & 5 deletions Source/Codecov/Url/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ private static string EscapeKnownProblematicCharacters(string data)
return result.ToString();
}

private void OverrideIfNotEmptyOrNull(string key, string value)
private void OverrideIfNotEmptyOrNull(string key, string value, bool escapeValue = false)
{
if (!string.IsNullOrWhiteSpace(value))
{
QueryParameters[key] = value.RemoveAllWhiteSpace();
QueryParameters[key] = escapeValue ?
Uri.EscapeDataString(value.RemoveAllWhiteSpace()) :
value.RemoveAllWhiteSpace();
}
}

Expand All @@ -77,8 +79,8 @@ private void SetBranch()
if (!string.IsNullOrWhiteSpace(repository.Branch))
{
// We also need to take into account that '#' needs to be escaped for parameters
// to work, but not '/'
QueryParameters["branch"] = EscapeKnownProblematicCharacters(repository.Branch);
var escapedBranch = EscapeKnownProblematicCharacters(Uri.EscapeDataString(repository.Branch));
QueryParameters["branch"] = escapedBranch;
break;
}
}
Expand All @@ -88,7 +90,9 @@ private void SetBranch()

private void SetBuild()
{
QueryParameters["build"] = Build.Build;
var escapedBuild = Uri.EscapeDataString(Build.Build);

QueryParameters["build"] = escapedBuild;
OverrideIfNotEmptyOrNull("build", Options.Build);
}

Expand Down
9 changes: 3 additions & 6 deletions nuspec/nuget/Codecov.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>Codecov global executable uploader.</summary>
<description>
Codecov global executable uploader for PowerShell and Windows Command Line.

**IMPORTANT:** This package only provides the Windows Compatible version of Codecov.
If there is a need to run Codecov on Unix platforms, then please use Codecov.Tool, or download platform specific Archives from our Releases page.
Codecov global executable uploader for PowerShell and .NET applications/libraries. Supports Windows, Linux and OSX.
</description>
<copyright>Copyright (c) 2017-Present Larz White, Kim J. Nordmo</copyright>
<releaseNotes>All release notes for Codecov can be found on the GitHub site - https://github.com/codecov/codecov-exe/releases/tag/$version$</releaseNotes>
<tags>coverage codecov</tags>
</metadata>
<files>
<file src="../../../codecov-windows-x64.exe" target="tools/codecov.exe" />
<file src="../../../codecov-linux-x64" target="runtimes/linux-x64/tools/codecov" />
<file src="../../../codecov-osx-x64" target="runtimes/osx-x64/tools/codecov" />
<file src="../../../codecov-linux-x64" target="tools/linux-x64/codecov" />
<file src="../../../codecov-osx-x64" target="tools/osx-x64/codecov" />
</files>
</package>

0 comments on commit 91286a2

Please sign in to comment.