-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
CreateSanitizedId should change to reflect HTML5 latest spec #4894
Comments
Thanks for contacting us, @doggy8088. |
Changes here are possible but not straightforward due to the need for a compatibility switch and the fact the methods involved are @doggy8088 what are the practical downside(s) i.e. bug(s) that result from MVC not being as relaxed about |
@dougbu If some Models defined non-ASCII characters as a property name, the |
If we're producing |
@rynowak this is about @doggy8088 what do you mean by "correct" or "right" Again, what are the practical downside(s) i.e. bug(s) that result from MVC not being as relaxed about |
@dougbu The right The main downside(s) of this issue is mainly for interacting with ASP.NET MVC Views and JavaScript. When we generate a list of input fields on the HTML and have to deal with it using JavaScript. That will be a big problem just because all the |
Please describe the errors you've experienced. Are you for example seeing multiple
Not quite sure what you mean here. Following associations between elements (e.g. an |
@dougbu Yes, sometimes we need I'm not telling about the |
🆗 we either need to ensure distinct |
I think this bug is simply about not sanitizing the id element (as HTML5 allows everything but spaces) so that it matches the property name when it contains non unicode characters and so that its exactly the same as the property name for purposes like interacting with the element through JavaScript. I'm not sure what transformations we do when we find non-ascii characters on the id, but if its not obvious, it clearly posses an issue when interacting through JavaScript. In theory we could do this, I don't think we need a compat switch for it, but just to announce the breaking change. We would have a switch to turn the old behavior back on, but you would be required to turn that on when you update (so as to not cause a big disruption for people using ids in their current javascript/css). Any obscure transformation we can avoid is a good thing, but we need to preserve this behavior to not disrupt existing apps. @rynowak Are you ok if we update here and provide a switch to go back to the old behavior? I think this leaves us in a better position moving forward. |
That sounds like a compat switch because I'm not sure why we'd preserve it going forward. I suspect we also need to change Microsoft.jQuery.Unobtrusive.Validation to support not doing the same transformations we've been doing forever. The hardest part will likely be linking that JavaScript switch to the compat switch. In any case, the JavaScript switch needs to preserve the existing behaviour by default because users may update the package before they update anything from this repo. |
@dougbu We would like to support older browsers where we can and give people some room to update. You are right in that we would have to update the jquery bits. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Hi. Thanks for contacting us. |
Is this a Bug or Feature request?:
Bug
Steps to reproduce (preferrably a link to a GitHub repo with a repro project):
Repo: https://github.com/doggy8088/ASPNETCORE_HTML5_Id
Steps:
git clone https://github.com/doggy8088/ASPNETCORE_HTML5_Id.git
cd ASPNETCORE_HTML5_Id/ASPNETCORE_HTML5_Id
dotnet run
id
attribute:Description of the problem:
Here is my model:
The HTML output become:
There is a
CreateSanitizedId
method in theMicrosoft.AspNetCore.Mvc.Rendering.TagBuilder
class. In this method, it sanitized all theid
attribute for all HTML tags to apply HTML4.01 spec for a long time which is no problem at all.The HTML 4.01 spec states that ID tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (-), underscores (_), colons (:), and periods (.). HTML5 gets rid of that restrictions on the
id
attribute now.For a modern web framework, I think it should align with the HTML5 specification and deprecated the old behavior.
Version of
Microsoft.AspNetCore.Mvc
orMicrosoft.AspNetCore.App
orMicrosoft.AspNetCore.All
:All of them. All versions.
The text was updated successfully, but these errors were encountered: