Skip to content

Better ContentType.Name validation on composed values #128637

Closed

Description

@mrek-msft

System.Net.Mail.Attachment (and likely AlternateView) has ContentType property which has Name property which itself has validation based on MimeBasePart.DecodeEncoding used in setter, however if encoding is detected at the beginning of string, it do not validate rest of it, allowing to interfere with other parts MailMessage/Attachment/AlternateView. For example, following code sent attachment with name foo.txt instead of test.txt as specified in constructor param.

var at = new Attachment("test.txt");
at.ContentType.Name = "=?utf-8?Q?foo\"; filename=\"foo.txt\"";

Activity

  1. self-assigned this
    on May 27, 2026
  2. added
    untriaged
    on May 27, 2026
  3. dotnet-policy-service commented on May 27, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @karelz, @dotnet/ncl
    See info in area-owners.md if you want to be subscribed.

  4. added this to the 11.0.0 milestone on Jun 2, 2026
  5. removed
    untriaged
    on Jun 2, 2026
  6. linked a pull request that will close this issueSystem.Net.Mail Validation improvements #128981on Jun 4, 2026
  7. removed their assignment
    on Jun 4, 2026
  8. changed the title [-]Better ContentType.Name validaiton on composed values[/-] [+]Better ContentType.Name validation on composed values[/+] on Jun 26, 2026
  9. modified the milestones: 11.0.0, 12.0.0 on Sep 9, 2026
  10. MihaZupan commented on Sep 24, 2026

    @MihaZupan
    Member

    Similar holds for other properties in the area, like ContentDisposition.DispositionType, AttachmentBase.ContentId ...

  11. locked and limited conversation to collaborators on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions