Lukasz Lenart created WW-5867:
---------------------------------

             Summary: JasperReports results write the Content-Disposition 
filename unquoted
                 Key: WW-5867
                 URL: https://issues.apache.org/jira/browse/WW-5867
             Project: Struts 2
          Issue Type: Bug
          Components: Plugin - JasperReports
            Reporter: Lukasz Lenart
             Fix For: 7.6.0


{{JasperReportsResult}} (plugin {{struts2-jasperreports-plugin}}) and 
{{JasperReport7Result}} (plugin {{struts2-jasperreports7-plugin}}) build the 
{{Content-disposition}} header by appending {{documentName}} + {{.}} + format 
as a bare token:

{code}
inline; filename=sales report.pdf
{code}

When the document name contains a space, {{;}}, {{"}} or a control character — 
common once {{documentName}} is an expression such as {{${title}}} evaluated 
against the value stack — the {{filename}} parameter is cut short or split, and 
browsers save the file under a truncated or wrong name.

h2. Proposed change

Write the file name as a quoted-string (RFC 6266 / RFC 9110): wrap it in double 
quotes, escape {{"}} and {{\}}, drop control characters.

{code}
inline; filename="sales report.pdf"
{code}

Applies to both plugins. Update the {{documentName}} Javadoc to show the quoted 
form.

h2. Tests

A test in each plugin asserting the header value for a document name containing 
a space, {{;}}, {{"}} and a control character.

Contributed by Naveed Khan (rootvector2) in 
https://github.com/apache/struts/pull/2150.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to