Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Content-Disposition header for HTTP reports with non-ASCII output file names #965

Merged
merged 1 commit into from
Feb 28, 2024
Merged
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
21 changes: 17 additions & 4 deletions dotnet/src/dotnetframework/GxClasses/Model/GXWebProcedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace GeneXus.Procedure
using System.Globalization;
using GeneXus.Http;
using GeneXus.Mime;
using System.Net.Mime;
#if NETCORE
using Microsoft.AspNetCore.Http;
#else
Expand All @@ -14,6 +15,7 @@ namespace GeneXus.Procedure

public class GXWebProcedure : GXHttpHandler
{
static readonly IGXLogger log = GXLoggerFactory.GetLogger<GXWebProcedure>();
protected int handle;

protected GXReportMetadata reportMetadata;
Expand Down Expand Up @@ -137,8 +139,19 @@ private void setOuputFileName()
{
fileType = outputType.ToLower();
}

context.HttpContext.Response.AddHeader(HttpHeader.CONTENT_DISPOSITION, $"inline; filename={fileName}.{fileType}");
try
{
ContentDisposition contentDisposition = new ContentDisposition
{
Inline = true,
FileName = $"{fileName}.{fileType}"
};
context.HttpContext.Response.AddHeader(HttpHeader.CONTENT_DISPOSITION, contentDisposition.ToString());
}
catch (Exception ex)
{
GXLogging.Warn(log, $"{HttpHeader.CONTENT_DISPOSITION} couldn't be set for {fileName}.{fileType}", ex);
}
}
}

Expand All @@ -152,9 +165,9 @@ protected bool initPrinter(String output, int gxXPage, int gxYPage, String iniFi
if (!Config.GetValueOf("LANGUAGE", out idiom))
idiom = "eng";
fileContentInline = true;
#if NETCORE

setOuputFileName();
#endif

getPrinter().GxRVSetLanguage(idiom);
int xPage = gxXPage;
int yPage = gxYPage;
Expand Down
Loading