Skip to content

[5.8] Convert percentage sign in filename fallback#28947

Merged
taylorotwell merged 4 commits into
laravel:5.8from
barryvdh:patch-12
Jun 25, 2019
Merged

[5.8] Convert percentage sign in filename fallback#28947
taylorotwell merged 4 commits into
laravel:5.8from
barryvdh:patch-12

Conversation

@barryvdh

@barryvdh barryvdh commented Jun 25, 2019

Copy link
Copy Markdown
Contributor

This is a follow-up to #28551, and similar to #6097 and how it's done in the current ResponseFactory:

public function download($file, $name = null, array $headers = [], $disposition = 'attachment')
{
$response = new BinaryFileResponse($file, 200, $headers, true, $disposition);
if (! is_null($name)) {
return $response->setContentDisposition($disposition, $name, $this->fallbackName($name));
}
return $response;
}
/**
* Convert the string to ASCII characters that are equivalent to the given name.
*
* @param string $name
* @return string
*/
protected function fallbackName($name)
{
return str_replace('%', '', Str::ascii($name));
}

The fallback can't include a percentage sign, so this check is added.

@taylorotwell taylorotwell merged commit 95292af into laravel:5.8 Jun 25, 2019
@barryvdh barryvdh deleted the patch-12 branch June 25, 2019 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants