Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

@Html.Id() implementation does not usefully sanitize return value, breaking JavaScript / CSS selectors #704

@dougbu

Description

@dougbu

We generate "sanitized" identifiers in most HTML helpers, substituting '_' for invalid characters. This is done for id attributes in input helpers, the for attribute in a label generated element, and so on. However it's not done for @Html.Id(), @Html.IdFor(), or @Html.IdForModel(). The current implementation of those methods match their @Html.Name() (and so on) equivalents.

Side note: Only whitespace characters are considered invalid now. But MVC 5.2 considers all but alphanumerics and a few special characters invalid. The limited number of invalid characters reduces the impact of this bug but there's still an impact. May also want to double-check what should be invalid and whether there's a reason to break compatibility with MVC 5.2 here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions