Commit graph

1231 commits

Author SHA1 Message Date
Chirayu Krishnappa
b99d064b6d fix(core): parse URLs using the browser's DOM API 2013-07-19 01:44:57 -07:00
Brian Ford
715d97d5c8 test(ngRepeat): add a test for ngRepeat when using 'track by' and a filter 2013-07-18 16:10:38 -07:00
Chirayu Krishnappa
3e39ac7e1b fix($compile): allow data: image URIs in img[src]
Ref: 1adf29af13

BREAKING CHANGE: img[src] URLs are now sanitized via a separate
    whitelist regex instead of sharing the whitelist regex with a[href].
    With this change, img[src] URLs may also be data: URI's matching
    mime types image/*.  mailto: URLs are disallowed (and do not make
    sense for img[src] but were allowed under the a[href] whitelist used
    before.)
2013-07-18 11:29:50 -07:00
Andreas Sander
2bb27d4998 feat(directive): ng:focus, ng:blur
Added directives for focus and blur events.

Closes #1277
2013-07-18 19:24:42 +02:00
James deBoer
711a493709 test(utils): Adds a missing test for snake_case 2013-07-16 11:18:04 -07:00
Matias Niemelä
031da1f96b fix($animator): ensure animations are always disabled for an element that is not attached to the DOM 2013-07-15 09:30:54 -07:00
Caio Cunha
2a5c355582 feat($q): added support to promise notification
It is now possible to notify a promise through deferred.notify() method.
Notifications are useful to provide a way to send progress information
to promise holders.
2013-07-14 23:11:46 -07:00
Chirayu Krishnappa
d884eb80a1 test($q): improve logging of callback invocations 2013-07-14 23:11:46 -07:00
Lucas Galfasó
a170fc1a74 feat(ngPluralize): add alternative mapping using attributes
Add an alternative way to define a mapping for ng:pluralize using
attributes instead of the `when` attribute

Closes #2454
2013-07-14 16:36:15 +02:00
Ben Ripkens
724819e3cf fix(angular.equals): add support for regular expressions
Regular expression objects didn't used to be considered to be equal when using
'angular.equals'. Dirty checking therefore failed to recognize a
property modification.

Closes #2685
2013-07-13 22:22:28 -07:00
Igor Minar
514dc0eb16 fix($http): allow interceptors to completely override headers
Closes #2770
2013-07-12 17:42:37 -07:00
Greg Thornton
5a294c8646 feat(Angular.js): skip JSON.stringify for undefined
Return early in `angular.toJson` if the object to be stringified is `undefined`.
IE8 stringifies `undefined` to `'undefined'` whereas other browsers return
`undefined`. This normalizes behavior and passes currently broken unit tests
in IE8.
2013-07-12 20:32:40 +02:00
Leandro Ostera
b94ca12fa0 feat($resource): support an unescaped URL port
The colon character is used to identify parameters in $resource.
This meant that we had to escape the colon used in a port.
It turns out that this is not necessary if we assume that parameter
names cannot consist of only digits.
If the parameter consists only of numbers, then it's a port.

Closes #2778
2013-07-12 10:47:46 +01:00
Stephen Merity
22a9b1ac07 fix(ngScenario): select().option(val) should prefer exact value match
With select(...).option(val) it previously would select the first node
which contains the value, even if an exact match was available.
This fix prefers exact matches if available, otherwise it reverts
to the previous 'contains' behaviour for backwards compatibility.

Closes #2856
2013-07-12 10:05:23 +01:00
Pete Bacon Darwin
7fef06fef9 fix(sanitize): match URI schemes case-insensitively
According to RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1)
schemes such as http or mailto are case-insensitive. So links such as
http://server/ and HTTP://server/ are valid and equivalent.

Closes #3210
2013-07-12 09:29:21 +01:00
Wesley Cho
3371fc254a fix(ngSubmit): expose $event to ngSubmit callback 2013-07-11 17:24:30 -07:00
Mikk Kirstein
09a1e7af12 fix(ngValue): made ngValue to write value attribute to element 2013-07-11 14:58:35 -07:00
Paulo Scardine
8bd6619b7e fix(scope): watches can be safely unregistered inside watch handlers
Closes #2915
2013-07-11 22:04:00 +01:00
Igor Minar
e82d780c2e fix($injector): improve $injector:nomod error message
Closes #2695
2013-07-11 12:16:02 -07:00
Igor Minar
03216760ec test(ngList): remove disabled test
this test fails and we don't have intentions on making it pass since
we never made a commitment to implement this feature.
2013-07-11 11:11:35 -07:00
bolasblack
a7150f1256 feat($http): accept function as headers value
So we can request with dynamic header value.

module.factory('Res', [
  '$resource'
  '$routeParams'
  'globalConfig'

function($resource, $routeParams, globalConfig) {
  resource('/url/:id', {id: "@id"}, {
    patch: {
      method: 'patch',
      headers: {
        'Authorization': function() {
          return "token " + globalConfig.token;
        }
      }
    }
  });
}]);
2013-07-08 08:55:20 -07:00
Daniel Luz
7829c50f9e fix(angular.equals): do not match keys defined in the prototype chain
Merely testing for object[key] will give incorrect results on keys
defined in Object.prototype.
Note: IE8 is generally broken in this regard since `for...in` never returns
certain property keys even if they are defined directly on the object.

See #2141 - partially merges this PR
2013-07-08 11:05:08 +01:00
Julien Bouquillon
ef5bc6c7c3 fix($sniffer): detect transition/animation on older Android browsers
The stock Android browser doesn't support the current for-in body/style
detection for animations and transitions but we can manually fix this.
This is useful for PhoneGap web-views or traditional web-apps using the
stock browser.
2013-07-03 22:16:31 +01:00
Chirayu Krishnappa
5349b20097 fix($parse): disallow access to Function constructor
Enhances sandboxing of Angular Expressions to prevent attacks via:

  {}.toString.constructor(alert("evil JS code"))
2013-07-03 00:03:56 -07:00
Joao Sa
fd87eb0ca5 fix(jqLite): prepend array in correct order
Match jQuery behavior when prepending array into empty element
2013-07-02 23:24:51 -07:00
Igor Minar
69f42b7654 fix($compile): prevent infinite loop w/ replace+transclude directives
Previously if a template contained a directive that had a template
(sync or async) and the directive template was to replace the original
element and the directive template contained another directive on the
root element of this template and this new directive was an element
transclude directive then an infinite recursion would follow because
the compiler kept on re-adding and reapplying the original directive
to the replaced node.

This change fixes that.

Closes #2155
2013-07-02 22:35:39 -07:00
Igor Minar
cbbe3bfe91 revert: fix(compiler): corrects component transclusion on ...
This reverts commit 15e1a29cd0.

The original commit was fixing two issues - one of them was
preventing attributes that triggered directives that replaced
the compiled node to be merged into the new node.

This change was a breaking change (as seen in the diff of the
tests in this commit) and that's why it's being removed.

A proper fix will follow.
2013-07-02 22:35:39 -07:00
Igor Minar
726e0c246b test(ngRepeat): disable an element directive test on IE8 2013-07-02 11:11:52 -07:00
Igor Minar
c46c5924c4 revert: test(ngRepeat): fix IE8 test compatibility issue
This reverts commit 0c6fb665a4.

The change invalidated the test because the point of the the test
was to test that an element directive works. Changing it to attribute
directive was wrong.
2013-07-02 11:07:59 -07:00
Igor Minar
4f0f243771 fix($injector): refactor module loading code and use minErr 2013-07-02 11:05:30 -07:00
Igor Minar
0c6fb665a4 test(ngRepeat): fix IE8 test compatibility issue 2013-07-01 14:30:43 -07:00
joshkurz
807394095b fix(Angular.js): handle duplicate params in parseKeyValue/toKeyValue
parseKeyValue and toKeyValue can now handle duplicate values in the query.
```
?x=1&x=2 <-> {x:[1,2]}
```

The algorithm looks like:
    1)parseKeyValue looks for presence of obj[key]
    2)detects and replaces obj[key] with [obj[key],val]
    3)then pushes more duplicates if necessary
    4)toKeyValue decodes array correctly
    5)(not changed)$location.search({param: 'key'}) still replaces if necessary
    6)(not changed)$location.search({param: ['key1', 'key2']}) sets the url with duplicates

BREAKING CHANGE: Before this change:
- `parseKeyValue` only took the last key overwriting all the previous keys;
- `toKeyValue` joined the keys together in a comma delimited string.
This was deemed buggy behavior. If your server relied on this behavior
then either the server should be fixed or a simple serialization of
the array should be done on the client before passing it to $location.
2013-07-01 19:32:12 +01:00
Chirayu Krishnappa
a22596c925 test($compile): use FQDN for img[src]
img[src]="https://foo" has the unfortunate problem that the browser will
actually try retrieving the resource the non FQDN foo.  The local DNS
might suffix a domain to this, resolve it, and try to present a
certificate for the https request and prompt the user to pick a
certificate. This commit avoids that by making foo a FQDN.  Note that it
might be better to replace foo with example.com (ref
http://tools.ietf.org/html/rfc2606#section-3).
2013-06-28 17:38:11 -07:00
Vojta Jina
89efb12ed8 chore: remove jstd leftovers 2013-06-28 11:43:38 -07:00
Pete Bacon Darwin
bd5c9a0371 style(ngRepeatSpec): fix up colons and iit 2013-06-28 08:28:06 +01:00
Igor Minar
15e1a29cd0 fix(compiler): corrects component transclusion on compilation root.
Closes# 2155
2013-06-27 21:30:24 -07:00
Igor Minar
aef0980063 fix($location): default to / for the url base if no base[href]
With the recent refactoring of $location service we changed this behavior
resulting in a regression.

Previously we thought that html5 mode always required base[href]
to be set in order for urls to resolve properly. It turns out that
base[href] is problematic because it makes anchor urls (#foo) to
always resolve to the base url, which is almost always incorrect
and results in all anchors links and other anchor urls (e.g. svg
references) to be broken.

For this reason, we should now start recommending that people just
deploy to root context (/) and not set the base[href] when using
the html5 mode (push/pop history state).

If it's impossible to deploy to the root context then either all
urls in the app must be absolute or base[href] must be set with the
caveat that anchor urls in such app won't work.

Closes #2762
2013-06-24 22:32:55 -07:00
Chirayu Krishnappa
0960cd0613 test($compile): fix IE specific test. 2013-06-24 21:02:01 -07:00
Chirayu Krishnappa
38deedd6e3 fix($compile): reject multi-expression interpolations for src attribute
BREAKING CHANGE: Concatenating expressions makes it hard to reason about
    whether some combination of concatenated values are unsafe to use
    and could easily lead to XSS.  By requiring that a single expression
    be used for *[src/ng-src] such as iframe[src], object[src], etc.
    (but not img[src/ng-src] since that value is sanitized), we ensure that the value
    that's used is assigned or constructed by some JS code somewhere
    that is more testable or make it obvious that you bound the value to
    some user controlled value.  This helps reduce the load when
    auditing for XSS issues.

    To migrate your code, follow the example below:

        Before:
            JS:
                scope.baseUrl = 'page';
                scope.a = 1;
                scope.b = 2;
            HTML:
                <!-- Are a and b properly escaped here? Is baseUrl
                     controlled by user? -->
                <iframe src="{{baseUrl}}?a={{a}&b={{b}}">

        After:
            JS:
                var baseUrl = "page";
                scope.getIframeSrc = function() {
                  // There are obviously better ways to do this.  The
                  // key point is that one will think about this and do
                  // it the right way.
                  var qs = ["a", "b"].map(function(value, name) {
                      return encodeURIComponent(name) + "=" +
                             encodeURIComponent(value);
                    }).join("&");
                  // baseUrl isn't on scope so it isn't bound to a user
                  // controlled value.
                  return baseUrl + "?" + qs;
                }
            HTML: <iframe src="{{getIframeSrc()}}">
2013-06-24 14:17:18 -07:00
Chirayu Krishnappa
39841f2ec9 fix($compile): disallow interpolations for DOM event handlers
BREAKING CHANGE: Interpolations inside DOM event handlers are
    disallowed.  DOM event handlers execute arbitrary Javascript code.
    Using an interpolation for such handlers means that the interpolated
    value is a JS string that is evaluated.  Storing or generating such
    strings is error prone and likely leads to an XSS if you're not
    super careful.  On the other hand, ng-click and such event handlers
    evaluate Angular expressions that are a lot safer (e.g. No direct
    access to global objects - only scope), cleaner and harder to
    exploit.

    To migrate the code follow the example below:

    Before:

        JS:   scope.foo = 'alert(1)';
        HTML: <div onclick="{{foo}}">

    After:

        JS:   scope.foo = function() { alert(1); }
        HTML: <div ng-click="foo()">
2013-06-21 17:37:44 -07:00
Chirayu Krishnappa
1adf29af13 fix($compile): sanitize values bound to img[src]
Ref: 9532234bf1

BREAKING CHANGE: img[src] URLs are now sanitized using the same whitelist
    as a[href] URLs.  The most obvious impact is if you were using data:
    URIs.  data: URIs will be whitelisted for img[src] in a future
    commit.
2013-06-21 17:26:42 -07:00
Pete Bacon Darwin
8264d08085 fix(Angular.js): don't crash on invalid query parameters 2013-06-20 14:13:16 +01:00
Caio Cunha
53359d549e fix($http): ensure case-insens. header overriding
If user send content-type header, both content-type and default
Content-Type headers were sent. Now default header overriding is
case-insensitive.
2013-06-19 21:30:59 +01:00
Michał Gołębiowski
f1b94b4b59 feat(jqLite): switch bind/unbind to more recent jQuery on/off
jQuery switched to a completely new event binding implementation as of
1.7.0, centering around on/off methods instead of previous bind/unbind.
This patch makes jqLite match this implementation while still supporting
previous bind/unbind methods.
2013-06-19 20:53:24 +01:00
Ken Sheedlo
003861d2fd chore(minErr): replace ngError with minErr 2013-06-17 13:29:30 -07:00
Misko Hevery
4953b49761 fix(ngRepeat): support growing over multi-element groups 2013-06-11 13:14:34 -07:00
Misko Hevery
b28f96949a fix($compile): support multi-element group over text nodes 2013-06-11 13:14:34 -07:00
Matias Niemelä
9faabd1ba0 chore(AngularPublic): remove angular.noConflict feature 2013-06-06 22:06:50 -07:00
Igor Minar
5599b55b04 refactor($route): pull $route and friends into angular-route.js
$route, $routeParams and ngView have been pulled from core angular.js
to angular-route.js/ngRoute module.

This is was done to in order keep the core focused on most commonly
used functionality and allow community routers to be freely used
instead of $route service.

There is no need to panic, angular-route will keep on being supported
by the angular team.

Note: I'm intentionally not fixing tutorial links. Tutorial will need
bigger changes and those should be done when we update tutorial to
1.2.

BREAKING CHANGE: applications that use $route will now need to load
angular-route.js file and define dependency on ngRoute module.

Before:

```
...
<script src="angular.js"></script>
...
var myApp = angular.module('myApp', ['someOtherModule']);
...
```

After:

```
...
<script src="angular.js"></script>
<script src="angular-route.js"></script>
...
var myApp = angular.module('myApp', ['ngRoute', 'someOtherModule']);
...
```

Closes #2804
2013-06-06 17:07:12 -07:00
Jeff Cross
e1a050e6b2 fix(jqLite): Added optional name arg in removeData
jQuery's API for removeData allows a second 'name' argument to just
remove the property by that name from an element's data. The absence
of this argument was causing some features not to work correctly when
combining multiple directives, such as ng-click, ng-show, and ng-animate.
2013-05-30 23:43:27 -07:00