Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dotnet/src/dotnetframework/GxClasses/Printer/GxPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2139,11 +2139,11 @@ public class ReportUtils
{
static public string AddPath(string name, string path)
{
if( name.IndexOf(":") != -1 ||
if (Path.IsPathRooted(name) || name.IndexOf(":") != -1 ||
(name.Length >=2 && (name.Substring( 0,2) == "//" || name.Substring( 0,2) == @"\\")) ||
(name.StartsWith("http:" ) || name.StartsWith("https:" )))
return name;
return path + name;
return Path.Combine(path, name);
}
}

Expand Down
28 changes: 28 additions & 0 deletions dotnet/test/DotNetUnitTest/FileIO/FileIOTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using GeneXus.Configuration;
using GeneXus.Printer;
using GeneXus.Utils;
using Xunit;

Expand Down Expand Up @@ -89,5 +90,32 @@ public void PathUtilGetValidFileName()
fileName = PathUtil.GetValidFileName(path, "_");
Assert.StartsWith("Screen Shot 2016-02-15 at 11.41.55 AM", fileName, StringComparison.OrdinalIgnoreCase);
}

[Fact]
public void ReportUtilAddPathLinux()
{
string name = "/mnt/c/Models/DockerReport/NETModel/Web/PublicTempStorage/clientreportebee6af4-7554-4283-b246-e1600e49b103.pdf";
string path = "/mnt/c/Models/DockerReport/NETModel/Web/";
string fullPath = ReportUtils.AddPath(name, path);
Assert.Equal(name, fullPath);
}

[Fact]
public void ReportUtilAddPathWindows()
{
string name = "PublicTempStorage/clientreportebee6af4-7554-4283-b246-e1600e49b103.pdf";
string path = "C:/Models/Report/NETModel/Web/";
string fullPath = ReportUtils.AddPath(name, path);

Assert.Equal(Path.Combine(path, name), fullPath);
}
[Fact]
public void ReportUtilAddPathHttp()
{
string name = "http://localhost:5000/WebApp/PublicTempStorage/clientreportebee6af4-7554-4283-b246-e1600e49b103.pdf";
string path = "C:/Models/Report/NETModel/Web/";
string fullPath = ReportUtils.AddPath(name, path);
Assert.Equal(name, fullPath);
}
}
}