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

Update TagHelperMatchingConventions to disallow opt-out prefix. #1187

Merged
merged 1 commit into from
Apr 6, 2017

Conversation

NTaylorMullen
Copy link
Member

  • Prior to this change the TagHelper parsing would strip the opt-out character (!) from tag names that got passed to the TagHelper matching services. At design time this proved to be a problem because they have their own understanding of the HTML document and only pass us full tag names (names that include !). This changes the matching conventions to immediately return false if a tag name is seen to contain the TagHelper opt-out.
  • Added two DefaultTagHelperFactService tests to verify that tag names with opt-out prefixes are denied TagHelperDescriptors.

#1186

@@ -66,6 +68,12 @@ public static bool SatisfiesTagName(string tagNameWithoutPrefix, TagMatchingRule
throw new ArgumentNullException(nameof(rule));
}

if (tagNameWithoutPrefix.Length > 0 && tagNameWithoutPrefix[0] == ElementOptOutCharacter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just reject anything with length == 0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure 👍

@@ -66,6 +68,12 @@ public static bool SatisfiesTagName(string tagNameWithoutPrefix, TagMatchingRule
throw new ArgumentNullException(nameof(rule));
}

if (tagNameWithoutPrefix.Length > 0 && tagNameWithoutPrefix[0] == ElementOptOutCharacter)
{
// TagHelper's can never satisfy tag names that are prefixed with the opt-out character.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TagHelpers

- Prior to this change the `TagHelper` parsing would strip the opt-out character (`!`) from tag names that got passed to the TagHelper matching services. At design time this proved to be a problem because they have their own understanding of the HTML document and only pass us full tag names (names that include `!`). This changes the matching conventions to immediately return false if a tag name is seen to contain the `TagHelper` opt-out.
- Added two `DefaultTagHelperFactService` tests to verify that tag names with opt-out prefixes are denied `TagHelperDescriptor`s.

#1186
@NTaylorMullen NTaylorMullen merged commit af3cf49 into dev Apr 6, 2017
@NTaylorMullen NTaylorMullen deleted the nimullen/thfs.1186 branch April 6, 2017 23:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants