-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($compile) empty href should pass sanitation check #2593
Conversation
Can you provide a unit test for this? |
I have attempted to create a unit test for this problem. Unfortunately it is very difficult to reproduce. The problem is in the following code from $compile: // sanitize a[href] values
if (nodeName_(this.$$element[0]) === 'A' && key === 'href') {
urlSanitizationNode.setAttribute('href', value);
// href property always returns normalized absolute url, so we can match against that
normalizedVal = urlSanitizationNode.href;
if (!normalizedVal.match(urlSanitizationWhitelist)) {
this[key] = value = 'unsafe:' + normalizedVal;
}
} Under NORMAL circumstances, the urlSanitizationNode.href returns a normalized absolute URL - including the problematic case, where the href is set to the empty string. However, under certain circumstances, which i don't fully understand, IE7 and IE8 returns an empty String. I cannot seem to reproduce this in a simple test case, and in my application the error is also not 100% reproducible - somtimes, it happens, sometimes it does not. |
The htmlAnchorDirective sets an empty href attribute on <a> tags. This should pass sanitation check in $compile. Closes #2219
Any updates to this? I'm still receiving "unsafe:" links on IE7 using ng-href. |
No updates that I know of, I do not think the angular devs will accept a bugfix without a test to reproduce the bug - which unfortunately is very difficult in this case. Have you been able to reproduce the bug in a small example? |
http://run.plnkr.co/BEpuj4YKdnSjbroM/ Try this out. It's been occurring precisely for me using routeProvider. |
I get a 404 when loading the plunk for some reason. I am sure it was available yesterday. Could you please upload it again? |
Sorry about that. Try this: http://run.plnkr.co/plunks/ImUdcyAWAHr63oWVbgxt/ And if not that, here's the plunkr directly: http://plnkr.co/ImUdcyAWAHr63oWVbgxt |
To get around this. You can add a non empty name attribute. <a href="" name="ie7Sucks" ng-click="[exp]">Click</a> |
Sometimes IE returns an empty string for its normalized href on a tags. This should pass the sanitation check in $compile. Closes angular#2219, angular#2593
Sometimes IE returns an empty string for its normalized href on a tags. This should pass the sanitation check in $compile. Closes angular#2219, angular#2593
The htmlAnchorDirective sets an empty href attribute on tags.
This should pass sanitation check in $compile.
Closes #2219