Repository: actix/actix-web
File: actix-http/src/header/common/content_disposition.rs (Rust)

Code before:
        };
        assert_eq!(a, b);
    }

    #[test]
    fn test_from_raw_semicolon() {
        let a =
            HeaderValue::from_static("form-data; filename=\"A semicolon here;.pdf\"");
        let a: ContentDisposition = ContentDisposition::from_raw(&a).unwrap();
        let b = ContentDisposition {
            disposition: DispositionType::FormData,
            parameters: vec![DispositionParam::Filename(String::from(
                "A semicolon here;.pdf",
            ))],
        };
        assert_eq!(a, b);
    }

    #[test]
    fn test_from_raw_uncessary_percent_decode() {
        // In fact, RFC7578 (multipart/form-data) Section 2 and 4.2 suggests that filename with
        // non-ASCII characters MAY be percent-encoded.
        // To the contrary, RFC6266 or other RFCs related to Content-Disposition response header
        // do not mention such percent-encoding.
        // So, it appears to be undecidable whether to percent-decode or not without
        // knowning the usage scenario (multipart/form-data v.s. HTTP response header) and
        // inevitable to unnecessarily percent-decode filename with %XX in the former scenario.
        // Fortunately, it seems that almost all mainstream browsers just send UTF-8 encoded file
        // names in quoted-string format (tested on Edge, IE11, Chrome and Firefox) without
        // percent-encoding. So we do not bother to attempt to percent-decode.
        let a = HeaderValue::from_static(
            "form-data; name=photo; filename=\"%74%65%73%74%2e%70%6e%67\"",
        );
        let a: ContentDisposition = ContentDisposition::from_raw(&a).unwrap();
        let b = ContentDisposition {
            disposition: DispositionType::FormData,
            parameters: vec![
                DispositionParam::Name("photo".to_owned()),
                DispositionParam::Filename(String::from("%74%65%73%74%2e%70%6e%67")),
            ],
        };
        assert_eq!(a, b);

        let a = HeaderValue::from_static(
            "form-data; name=photo; filename=\"%74%65%73%74.png\"",
        );
        let a: ContentDisposition = ContentDisposition::from_raw(&a).unwrap();
        let b = ContentDisposition {
            disposition: DispositionType::FormData,
            parameters: vec![
                DispositionParam::Name("photo".to_owned()),

Review comment (suggestion):
```suggestion
        // knowing the usage scenario (multipart/form-data v.s. HTTP response header) and
```

Code after:
        };
        assert_eq!(a, b);
    }

    #[test]
    fn test_from_raw_semicolon() {
        let a =
            HeaderValue::from_static("form-data; filename=\"A semicolon here;.pdf\"");
        let a: ContentDisposition = ContentDisposition::from_raw(&a).unwrap();
        let b = ContentDisposition {
            disposition: DispositionType::FormData,
            parameters: vec![DispositionParam::Filename(String::from(
                "A semicolon here;.pdf",
            ))],
        };
        assert_eq!(a, b);
    }

    #[test]
    fn test_from_raw_uncessary_percent_decode() {
        // In fact, RFC7578 (multipart/form-data) Section 2 and 4.2 suggests that filename with
        // non-ASCII characters MAY be percent-encoded.
        // On the contrary, RFC6266 or other RFCs related to Content-Disposition response header
        // do not mention such percent-encoding.
        // So, it appears to be undecidable whether to percent-decode or not without
        // knowing the usage scenario (multipart/form-data v.s. HTTP response header) and
        // inevitable to unnecessarily percent-decode filename with %XX in the former scenario.
        // Fortunately, it seems that almost all mainstream browsers just send UTF-8 encoded file
        // names in quoted-string format (tested on Edge, IE11, Chrome and Firefox) without
        // percent-encoding. So we do not bother to attempt to percent-decode.
        let a = HeaderValue::from_static(
            "form-data; name=photo; filename=\"%74%65%73%74%2e%70%6e%67\"",
        );
        let a: ContentDisposition = ContentDisposition::from_raw(&a).unwrap();
        let b = ContentDisposition {
            disposition: DispositionType::FormData,
            parameters: vec![
                DispositionParam::Name("photo".to_owned()),
                DispositionParam::Filename(String::from("%74%65%73%74%2e%70%6e%67")),
            ],
        };
        assert_eq!(a, b);

        let a = HeaderValue::from_static(
            "form-data; name=photo; filename=\"%74%65%73%74.png\"",
        );
        let a: ContentDisposition = ContentDisposition::from_raw(&a).unwrap();
        let b = ContentDisposition {
            disposition: DispositionType::FormData,
            parameters: vec![
                DispositionParam::Name("photo".to_owned()),