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
12 changes: 11 additions & 1 deletion dotnet/src/dotnetframework/GxClasses/Printer/GxPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace GeneXus.Printer
using System.Threading;
using System.Threading.Tasks;
using GeneXus.Configuration;
using GeneXus.Utils;
using GeneXus.XML;

public interface IPrintHandler
Expand Down Expand Up @@ -2162,10 +2163,19 @@ public class ReportUtils
{
static public string AddPath(string name, string path)
{
if (Path.IsPathRooted(name) || name.IndexOf(":") != -1 ||
if (name.IndexOf(":") != -1 ||
(name.Length >=2 && (name.Substring( 0,2) == "//" || name.Substring( 0,2) == @"\\")) ||
(name.StartsWith("http:" ) || name.StartsWith("https:" )))
return name;
#if NETCORE
if (Path.IsPathRooted (name))
return name;
#else
if (PathUtil.IsValidFilePath(name) && Path.IsPathRooted(name))
{
return name;
}
#endif
return Path.Combine(path, name);
}
}
Expand Down
10 changes: 10 additions & 0 deletions dotnet/test/DotNetUnitTest/FileIO/FileIOTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,15 @@ public void ReportUtilAddPathHttp()
string fullPath = ReportUtils.AddPath(name, path);
Assert.Equal(name, fullPath);
}
[Fact]
public void ReportUtilAddPathWithIllegalCharacters()
{
string name = "https://chart.googleapis.com/chart?chs=400x400&cht=qr&chl=http://sistemas.gov/nfceweb/consultarNFCe.jsp?p=13231205514674000128650020009504049878593990|2|1|09|1337.07|4558626967746769617A304E4B7A6D34504B4E61524A474F4D32513D|1|14D0A30916C6C7EA709E7E33E330EE3F290FE25D";
string path = "C:/Models/Report/NETModel/Web/";
string fullPath = ReportUtils.AddPath(name, path);

Assert.Equal(name, fullPath);
}

}
}