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

Commit

Permalink
React to aspnet/Razor#684.
Browse files Browse the repository at this point in the history
- Modified `UrlResolutionTagHelper` to utilize new CSS selector attributes to restrict when it applies. It now only appies to tags that have their values starting with `~/`.
- `UrlResolutionTagHelper` no longer applies to dynamic content such as `href="@SomethingResultingInTildaSlash"`.
- Updated tests to reflect new behavior.
  • Loading branch information
NTaylorMullen committed Mar 8, 2016
1 parent f3740b2 commit 5612ca8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,35 @@ namespace Microsoft.AspNetCore.Mvc.Razor.TagHelpers
/// <remarks>Resolves URLs starting with '~/' (relative to the application's 'webroot' setting) that are not
/// targeted by other <see cref="ITagHelper"/>s. Runs prior to other <see cref="ITagHelper"/>s to ensure
/// application-relative URLs are resolved.</remarks>
[HtmlTargetElement("*", Attributes = "itemid")]
[HtmlTargetElement("a", Attributes = "href")]
[HtmlTargetElement("applet", Attributes = "archive")]
[HtmlTargetElement("area", Attributes = "href", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("audio", Attributes = "src")]
[HtmlTargetElement("base", Attributes = "href", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("blockquote", Attributes = "cite")]
[HtmlTargetElement("button", Attributes = "formaction")]
[HtmlTargetElement("del", Attributes = "cite")]
[HtmlTargetElement("embed", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("form", Attributes = "action")]
[HtmlTargetElement("html", Attributes = "manifest")]
[HtmlTargetElement("iframe", Attributes = "src")]
[HtmlTargetElement("img", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("img", Attributes = "srcset", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("input", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("input", Attributes = "formaction", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("ins", Attributes = "cite")]
[HtmlTargetElement("link", Attributes = "href", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("menuitem", Attributes = "icon")]
[HtmlTargetElement("object", Attributes = "archive")]
[HtmlTargetElement("object", Attributes = "data")]
[HtmlTargetElement("q", Attributes = "cite")]
[HtmlTargetElement("script", Attributes = "src")]
[HtmlTargetElement("source", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("source", Attributes = "srcset", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("track", Attributes = "src", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("video", Attributes = "src")]
[HtmlTargetElement("video", Attributes = "poster")]
[HtmlTargetElement("*", Attributes = "[itemid^='~/']")]
[HtmlTargetElement("a", Attributes = "[href^='~/']")]
[HtmlTargetElement("applet", Attributes = "[archive^='~/']")]
[HtmlTargetElement("area", Attributes = "[href^='~/']", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("audio", Attributes = "[src^='~/']")]
[HtmlTargetElement("base", Attributes = "[href^='~/']", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("blockquote", Attributes = "[cite^='~/']")]
[HtmlTargetElement("button", Attributes = "[formaction^='~/']")]
[HtmlTargetElement("del", Attributes = "[cite^='~/']")]
[HtmlTargetElement("embed", Attributes = "[src^='~/']", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("form", Attributes = "[action^='~/']")]
[HtmlTargetElement("html", Attributes = "[manifest^='~/']")]
[HtmlTargetElement("iframe", Attributes = "[src^='~/']")]
[HtmlTargetElement("img", Attributes = "[src^='~/']", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("img", Attributes = "[srcset^='~/']", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("input", Attributes = "[src^='~/']", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("input", Attributes = "[formaction^='~/']", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("ins", Attributes = "[cite^='~/']")]
[HtmlTargetElement("link", Attributes = "[href^='~/']", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("menuitem", Attributes = "[icon^='~/']")]
[HtmlTargetElement("object", Attributes = "[archive^='~/']")]
[HtmlTargetElement("object", Attributes = "[data^='~/']")]
[HtmlTargetElement("q", Attributes = "[cite^='~/']")]
[HtmlTargetElement("script", Attributes = "[src^='~/']")]
[HtmlTargetElement("source", Attributes = "[src^='~/']", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("source", Attributes = "[srcset^='~/']", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("track", Attributes = "[src^='~/']", TagStructure = TagStructure.WithoutEndTag)]
[HtmlTargetElement("video", Attributes = "[src^='~/']")]
[HtmlTargetElement("video", Attributes = "[poster^='~/']")]
[EditorBrowsable(EditorBrowsableState.Never)]
public class UrlResolutionTagHelper : TagHelper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<a href="HtmlEncode[[/]]Person">Person</a>
<area href="HtmlEncode[[/]]Person/HtmlEncode[[John Doe]]" alt="Url stuff">
<link href="HtmlEncode[[/]]Person/HtmlEncode[[John Doe]]/CSS" rel="stylesheet">
<video poster="HtmlEncode[[~/SomeUrl]]" src="HtmlEncode[[~/SomeUrl]]/HtmlEncode[[video]]" />
<video poster=HtmlEncode[[~/SomeUrl]] src='HtmlEncode[[~/SomeUrl]]/HtmlEncode[[video]]' />
<audio src="HtmlEncode[[~/SomeUrl]]">
<source src="HtmlEncode[[/]]Person" srcset="HtmlEncode[[/]]Person">
<track src="HtmlEncode[[/]]emailHtmlEncode[[~/SomeUrl]]">
</audio>
<embed src="HtmlEncode[[/]]email@dyanmicUrl">
<iframe src="HtmlEncode[[~/SomeUrl]]" />
<iframe src=HtmlEncode[[~/SomeUrl]] />
<img src="HtmlEncode[[/]]HtmlEncode[[John Doe]]" srcset="HtmlEncode[[/]]HtmlEncode[[John Doe]]">
<script src="HtmlEncode[[/]]Person/HtmlEncode[[John Doe]]/JS"></script>
<input src="HtmlEncode[[/]]/Person" itemscope itemid="HtmlEncode[[/]]Person" formaction="HtmlEncode[[~/SomeUrl]]">
Expand All @@ -27,7 +27,7 @@
<menuitem icon="HtmlEncode[[/]]Person" />
</menu>
<object data="HtmlEncode[[/]]Person" archive="HtmlEncode[[/]]Person/HtmlEncode[[John Doe]]" data="HtmlEncode[[/]]Person" archive="HtmlEncode[[/]]Person/HtmlEncode[[John Doe]]" />
<object archive="HtmlEncode[[/]]Person/HtmlEncode[[John Doe]]" />
<object archive="~/Person/HtmlEncode[[John Doe]] " />
<applet archive="HtmlEncode[[/]]A+Really(Crazy),Url.Is:This/HtmlEncode[[John Doe]]/Detail" />
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<a href="/Person">Person</a>
<area href="/Person/John Doe" alt="Url stuff">
<link href="/Person/John Doe/CSS" rel="stylesheet">
<video poster="/SomeUrl" src="/SomeUrl/video" />
<audio src="/SomeUrl">
<video poster=~/SomeUrl src='~/SomeUrl/video' />
<audio src="~/SomeUrl">
<source src="/Person" srcset="/Person">
<track src="/email~/SomeUrl">
</audio>
<embed src="/email@dyanmicUrl">
<iframe src="/SomeUrl" />
<iframe src=~/SomeUrl />
<img src="/John Doe" srcset="/John Doe">
<script src="/Person/John Doe/JS"></script>
<input src="//Person" itemscope itemid="/Person" formaction="/SomeUrl">
Expand All @@ -27,7 +27,7 @@
<menuitem icon="/Person" />
</menu>
<object data="/Person" archive="/Person/John Doe" data="/Person" archive="/Person/John Doe" />
<object archive="/Person/John Doe" />
<object archive="~/Person/John Doe " />
<applet archive="/A+Really(Crazy),Url.Is:This/John Doe/Detail" />
</body>
</html>

0 comments on commit 5612ca8

Please sign in to comment.