vaadin / vaadin/framework

getContentDispositionFilename uses encodedFilename in both parameters where decoded one should be used

Open
#12,591 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

/**
 * Returns the filename formatted for inclusion in a Content-Disposition
 * header. Includes both a plain version of the name and a UTF-8 version
 *
 * @since 7.4.8
 * @param filename
 *            The filename to include
 * @return A value for inclusion in a Content-Disposition header
 */
public static String getContentDispositionFilename(String filename) {
    String encodedFilename = EncodeUtil.rfc5987Encode(filename);

    return String.format("filename=\"%s\"; filename*=utf-8''%s",
            encodedFilename, encodedFilename);

Observe that you use encodedFilename in both cases instead of using filename in one case and encodedFilename in the other.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at getContentDispositionFilename(String filename) and inspect how EncodeUtil.rfc5987Encode(filename) is used to build the Content-Disposition value. Verify that the plain filename parameter uses the original filename while the UTF-8 parameter uses the encoded value, then run the relevant project tests or add coverage for both parameters.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.