-
Notifications
You must be signed in to change notification settings - Fork 155
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 invalid Content-Disposition #357
Conversation
To give a bit more context on this header, it's useful when having template variables in panel titles. Grafana backend can't interpolate template variables so if we send an empty file name, it will work fine for panel titles that don't contain template variable but will show something like Also, I noticed the regex you used is a bit too broad. I couldn't find a rule but not all non-ascii characters are causing the error, german characters like in However, when researching for the characters that were actually breaking the I tested this change and it seems to work fine: What do you think? |
Thanks Agnès! I was more scared about breaking things and I didn't notice about variables in titles. I'm going to test it. |
@@ -234,7 +235,7 @@ export class HttpServer { | |||
const result = await this.browser.renderCSV(options); | |||
|
|||
if (result.fileName) { | |||
res.setHeader('Content-Disposition', `attachment; filename="${result.fileName}"`); | |||
res.setHeader('Content-Disposition', contentDisposition(result.fileName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the file name is expected to contains special characters - will they be simply removed?
It uses
content-disposition
library to accept non-ascii characters in Content-Disposition header. Right now its failing when it's happening and we aren't creating the csv.Related issue: https://github.com/grafana/grafana-enterprise/issues/3576