Skip to content

C#: AttributeCollection is no longer considered a HTML sink. #17582

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

Merged

Conversation

michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Sep 25, 2024

In this PR we remove the indexer and Add method of System.Web.UI.AttributeCollection as possible HTML sinks as the information is HTML encoded when the control is rendered.

This can be confirmed by running (needs to be a .NET Framework app).

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

class Program
{
    static void Main(string[] args)
    {
        Button b = new Button();
        b.Attributes.Add("my_key", "<some value & my stuff");
        b.Attributes["my_index_key"] = "my_<index&_value";
        b.RenderControl(new HtmlTextWriter(Console.Out));
    }
}

@michaelnebel michaelnebel changed the title C#: AttributeCollections are no longer considered HTML sinks. C#: AttributeCollection is no longer considered a HTML sink. Sep 25, 2024
@michaelnebel michaelnebel force-pushed the csharp/attributecollectionsinks branch from 1c2e36d to af80797 Compare September 25, 2024 12:13
@michaelnebel michaelnebel marked this pull request as ready for review September 25, 2024 13:39
@michaelnebel michaelnebel requested a review from a team as a code owner September 25, 2024 13:39
@michaelnebel
Copy link
Contributor Author

DCA looks good!

@michaelnebel michaelnebel merged commit 297d321 into github:main Sep 26, 2024
22 checks passed
@michaelnebel michaelnebel deleted the csharp/attributecollectionsinks branch September 26, 2024 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants