Commit Graph

72 Commits

Author SHA1 Message Date
Brian Ford
94ec84e7b9 chore(ngMobile): rename module ngTouch and file to angular-touch.js
BREAKING CHANGE: since all the code in the ngMobile module is touch related,
we are renaming the module to ngTouch.

To migrate, please replace all references to "ngMobile" with "ngTouch" and
"angular-mobile.js" to "angular-touch.js".

Closes #3526
2013-08-09 11:54:35 -07:00
Ken Sheedlo
576269b1b7 fix(bower): update bower usage and resources
Changes:
- Fix our old code to use bower_components/ as the install dir
- Fix the Bootstrap asset to use github.com/twbs/bootstrap (it moved)
- Fail the build on Bower failure. Bower should not fail silently.
2013-07-29 17:26:01 -07:00
Matias Niemelä
81923f1e41 feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
  - $animate.enter(element, parent, after, done);
  - $animate.leave(element, done);
  - $animate.move(element, parent, after, done);
  - $animate.addClass(element, className, done);
  - $animate.removeClass(element, className, done);

BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-07-26 23:49:54 -07:00
Chirayu Krishnappa
dae694739b feat(ngBindHtml, sce): combine ng-bind-html and ng-bind-html-unsafe
Changes:
- remove ng-bind-html-unsafe
- ng-bind-html is now in core
- ng-bind-html is secure
  - supports SCE - so you can bind to an arbitrary trusted string
  - automatic sanitization if $sanitize is available

BREAKING CHANGE:
  ng-html-bind-unsafe has been removed and replaced by ng-html-bind
  (which has been removed from ngSanitize.)  ng-bind-html provides
  ng-html-bind-unsafe like behavior (innerHTML's the result without
  sanitization) when bound to the result of $sce.trustAsHtml(string).
  When bound to a plain string, the string is sanitized via $sanitize
  before being innerHTML'd.  If $sanitize isn't available, it's logs an
  exception.
2013-07-25 14:29:56 -07:00
Chirayu Krishnappa
bea9422ebf feat($sce): new $sce service for Strict Contextual Escaping.
$sce is a service that provides Strict Contextual Escaping services to AngularJS.

Strict Contextual Escaping
--------------------------

Strict Contextual Escaping (SCE) is a mode in which AngularJS requires
bindings in certain contexts to result in a value that is marked as safe
to use for that context One example of such a context is binding
arbitrary html controlled by the user via ng-bind-html-unsafe.  We
refer to these contexts as privileged or SCE contexts.

As of version 1.2, Angular ships with SCE enabled by default.

Note:  When enabled (the default), IE8 in quirks mode is not supported.
In this mode, IE8 allows one to execute arbitrary javascript by the use
of the expression() syntax.  Refer
http://blogs.msdn.com/b/ie/archive/2008/10/16/ending-expressions.aspx
to learn more about them.  You can ensure your document is in standards
mode and not quirks mode by adding <!doctype html> to the top of your
HTML document.

SCE assists in writing code in way that (a) is secure by default and (b)
makes auditing for security vulnerabilities such as XSS, clickjacking,
etc. a lot easier.

Here's an example of a binding in a privileged context:

  <input ng-model="userHtml">
  <div ng-bind-html-unsafe="{{userHtml}}">

Notice that ng-bind-html-unsafe is bound to {{userHtml}} controlled by
the user.  With SCE disabled, this application allows the user to render
arbitrary HTML into the DIV.  In a more realistic example, one may be
rendering user comments, blog articles, etc. via bindings.  (HTML is
just one example of a context where rendering user controlled input
creates security vulnerabilities.)

For the case of HTML, you might use a library, either on the client side, or on the server side,
to sanitize unsafe HTML before binding to the value and rendering it in the document.

How would you ensure that every place that used these types of bindings was bound to a value that
was sanitized by your library (or returned as safe for rendering by your server?)  How can you
ensure that you didn't accidentally delete the line that sanitized the value, or renamed some
properties/fields and forgot to update the binding to the sanitized value?

To be secure by default, you want to ensure that any such bindings are disallowed unless you can
determine that something explicitly says it's safe to use a value for binding in that
context.  You can then audit your code (a simple grep would do) to ensure that this is only done
for those values that you can easily tell are safe - because they were received from your server,
sanitized by your library, etc.  You can organize your codebase to help with this - perhaps
allowing only the files in a specific directory to do this.  Ensuring that the internal API
exposed by that code doesn't markup arbitrary values as safe then becomes a more manageable task.

In the case of AngularJS' SCE service, one uses $sce.trustAs (and
shorthand methods such as $sce.trustAsHtml, etc.) to obtain values that
will be accepted by SCE / privileged contexts.

In privileged contexts, directives and code will bind to the result of
$sce.getTrusted(context, value) rather than to the value directly.
Directives use $sce.parseAs rather than $parse to watch attribute
bindings, which performs the $sce.getTrusted behind the scenes on
non-constant literals.

As an example, ngBindHtmlUnsafe uses $sce.parseAsHtml(binding
expression).  Here's the actual code (slightly simplified):

  var ngBindHtmlUnsafeDirective = ['$sce', function($sce) {
    return function(scope, element, attr) {
      scope.$watch($sce.parseAsHtml(attr.ngBindHtmlUnsafe), function(value) {
        element.html(value || '');
      });
    };
  }];

Impact on loading templates
---------------------------

This applies both to the ng-include directive as well as templateUrl's
specified by directives.

By default, Angular only loads templates from the same domain and
protocol as the application document.  This is done by calling
$sce.getTrustedResourceUrl on the template URL.  To load templates from
other domains and/or protocols, you may either either whitelist them or
wrap it into a trusted value.

*Please note*:
The browser's Same Origin Policy and Cross-Origin Resource Sharing
(CORS) policy apply in addition to this and may further restrict whether
the template is successfully loaded.  This means that without the right
CORS policy, loading templates from a different domain won't work on all
browsers.  Also, loading templates from file:// URL does not work on
some browsers.

This feels like too much overhead for the developer?
----------------------------------------------------

It's important to remember that SCE only applies to interpolation expressions.

If your expressions are constant literals, they're automatically trusted
and you don't need to call $sce.trustAs on them.
e.g.  <div ng-html-bind-unsafe="'<b>implicitly trusted</b>'"></div> just works.

Additionally, a[href] and img[src] automatically sanitize their URLs and
do not pass them through $sce.getTrusted.  SCE doesn't play a role here.

The included $sceDelegate comes with sane defaults to allow you to load
templates in ng-include from your application's domain without having to
even know about SCE.  It blocks loading templates from other domains or
loading templates over http from an https served document.  You can
change these by setting your own custom whitelists and blacklists for
matching such URLs.

This significantly reduces the overhead.  It is far easier to pay the
small overhead and have an application that's secure and can be audited
to verify that with much more ease than bolting security onto an
application later.
2013-07-25 13:00:35 -07:00
Chirayu Krishnappa
b99d064b6d fix(core): parse URLs using the browser's DOM API 2013-07-19 01:44:57 -07:00
Vojta Jina
976edc1fc4 chore: clean up angularFiles.js 2013-06-28 11:43:38 -07:00
Vojta Jina
89efb12ed8 chore: remove jstd leftovers 2013-06-28 11:43:38 -07:00
Ken Sheedlo
003861d2fd chore(minErr): replace ngError with minErr 2013-06-17 13:29:30 -07:00
Matias Niemelä
ba3ca0be41 fix(angularFiles): ensure only karma-docs.js tests the component-spec files 2013-06-10 18:16:57 -04:00
Matias Niemelä
77c4fc6847 chore(ngdocs): setup karma-docs testing suite to test docs components 2013-06-06 22:58:56 -07:00
Matias Niemelä
f56125d94e chore(ngdocs): setup bower as the package manager for the docs pages 2013-06-06 22:58:55 -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
Igor Minar
b8ea7f6aba feat(ngError): add error message compression and better error messages
- add toThrowNg matcher
2013-05-24 17:03:21 -07:00
Braden Shepherdson
f4c6b2c789 feat($swipe): Refactor swipe logic from ngSwipe to $swipe service.
This new service is used by the ngSwipeLeft/Right directives, and by the
separate ngCarousel and swipe-to-delete directives which are under
development.
2013-05-23 16:07:44 -07:00
Matias Niemelä
2f571a9c83 chore(ngdocs): move angular-bootstrap.js to be generated only inside the docs and remove from the build process 2013-05-20 14:27:34 -07:00
Oren Avissar
2f96fbd175 feat(ngIf): add directive to remove and recreate DOM elements
This directive is adapted from ui-if in the AngularUI project and provides a complement
to the ngShow/ngHide directives that only change the visibility of the DOM element and
ngSwitch which does change the DOM but is more verbose.
2013-04-19 21:45:38 +01:00
Igor Minar
5da6b125a7 test(modules): fix module tests which got disabled by ngMobile
When ngMobile was merged in, we accidentaly included angular-scenario.js
in the test file set for modules. Loading this file overrode jasmine's
`it` and `describe` global functions which essentially disabled all of
~200 unit tests for wrapped modules.

This change refactors the code to run the wrapped module tests.

I had to extract browserTrigger from scenario runner in order to achieve
this without code duplication.
2013-04-18 14:34:53 -07:00
Braden Shepherdson
5e0f876c39 feat(ngSwipe): Add ngSwipeRight/Left directives to ngMobile
These directives fire an event handler on a touch-and-drag or
click-and-drag to the left or right. Includes unit tests and docs
update. Manually tested on Chrome 26, IE8, Android Chrome and iOS
Safari.
2013-04-11 13:01:24 -07:00
Misko Hevery
820253f670 chore(revert): accidental inclusion of nonexistent test.
Offending SHA: 0b6f1ce5f8
2013-04-03 14:54:16 -07:00
Misko Hevery
0b6f1ce5f8 feat(ngAnimate): add support for animation 2013-04-02 14:05:06 -07:00
Vojta Jina
c2e215fab6 chore: use Karma 2013-04-01 12:24:27 -07:00
Braden Shepherdson
707c65d5a2 feat(ngMobile): add ngMobile module with mobile-specific ngClick
Add a new module ngMobile, with mobile/touch-specific directives.
Add ngClick, which overrides the default ngClick. This ngClick uses touch
events, which are much faster on mobile. On desktop browsers, ngClick
responds to click events, so it can be used for portable sites.
2013-03-13 22:59:06 -07:00
James deBoer
8c269883fd chore(Rakefile): remove a duplicate file in angularFiles.js 2013-01-16 23:45:09 -08:00
Igor Minar
9d168f058f chore(testing): Testacular config files + rake tasks
- adds testacular config files for jqlite, jquery, modules and e2e tests
- replaces obsolete JsTD Rake tasks with Testacular onces
- rake tasks are parameterazied so that they can be used locally as well as on CI server

usage:

rake test  # run all tests on Chrome
rake test[Safari+Chrome+Opera]  # run all tests on Safari, Chrome and Opera
rake test[Safari]  # run all tests on Safari
rake test:jqlite # run unit tests using jqlite on Chrome
rake test:jqlite[Safari,"--reporter=dots"]  # run jqlite-based unit tests on Safari with dots reporter
rake autotest:jquery  # start testacular with jquery-based config and watch fs for changes
rake test:e2e # run end to end tests
2012-09-13 16:23:18 -07:00
Igor Minar
9af7a9198e fix($defer): remove deprecated $defer service 2012-06-12 01:09:07 -07:00
Igor Minar
4511d39cc7 feat($timeout): add $timeout service that supersedes $defer
$timeout has a better name ($defer got often confused with something related to $q) and
is actually promise based with cancelation support.

With this commit the $defer service is deprecated and will be removed before 1.0.

Closes #704, #532
2012-05-23 15:00:56 -07:00
Misko Hevery
aa02534865 bug(ie8 docs): docs now work on ie8 2012-05-07 15:43:09 -07:00
Misko Hevery
8e2675029f chore(docs): re-skin main documentation 2012-05-04 16:12:17 -07:00
Igor Minar
beea3a4bed style($compile): rename compiler.js to compile.js 2012-05-02 16:37:48 -07:00
Igor Minar
2b87c814ab feat($parse): CSP compatibility
CSP (content security policy) forbids apps to use eval or
Function(string) generated functions (among other things). For us to be
compatible, we just need to implement the "getterFn" in $parse without
violating any of these restrictions.

We currently use Function(string) generated functions as a speed
optimization. With this change, it will be possible to opt into the CSP
compatible mode using the ngCsp directive. When this mode is on Angular
will evaluate all expressions up to 30% slower than in non-CSP mode, but
no security violations will be raised.

In order to use this feature put ngCsp directive on the root element of
the application. For example:

<!doctype html>
<html ng-app ng-csp>
  ...
  ...
</html>

Closes #893
2012-04-27 23:04:24 -07:00
Vojta Jina
5bcd719866 chore(ngSanitize): extract $sanitize, ngBindHtml, linkyFilter into a module
Create build for other modules as well (ngResource, ngCookies):
- wrap into a function
- add license
- add version

Breaks `$sanitize` service, `ngBindHtml` directive and `linky` filter were moved to the `ngSanitize` module. Apps that depend on any of these will need to load `angular-sanitize.js` and include `ngSanitize` in their dependency list: `var myApp = angular.module('myApp', ['ngSanitize']);`
2012-04-11 15:50:47 -07:00
Vojta Jina
02cf958a07 chore(directive): correct file names for booleanAttrs 2012-04-04 14:58:27 -07:00
Igor Minar
af0ad6561c refactor(fromJson/toJson): move the contents of these files into Angular.js
these files are now mostly empty so it doesn't make sense to keep them
separated from other helper functions
2012-03-28 16:57:34 -07:00
Misko Hevery
7b22d59b4a chore(ngCookies): moved to module 2012-03-28 11:16:36 -07:00
Misko Hevery
798bca62c6 chore(resource): moved to module 2012-03-28 11:16:36 -07:00
Misko Hevery
8218c4b60b chore(Rakefile): get ready for modules 2012-03-28 11:16:36 -07:00
Misko Hevery
2430f52bb9 chore(module): move files around in preparation for more modules 2012-03-28 11:16:35 -07:00
Igor Minar
6a8749e65a refactor($resource): unify and simplify the code 2012-03-20 11:07:38 -07:00
Igor Minar
f54db2ccda chore(directives,widgets): reorg the code under directive/ dir 2012-03-08 22:29:34 -08:00
Vojta Jina
bbd3a3fd76 chore: Update slim-jim 2012-03-05 09:59:29 -08:00
Vojta Jina
21c725f1a1 refactor(forms): Even better forms
- remove $formFactory completely
- remove parallel scope hierarchy (forms, widgets)
- use new compiler features (widgets, forms are controllers)
- any directive can add formatter/parser (validators, convertors)

Breaks no custom input types
Breaks removed integer input type
Breaks remove list input type (ng-list directive instead)
Breaks inputs bind only blur event by default (added ng:bind-change directive)
2012-02-28 17:46:58 -08:00
Misko Hevery
292a5dae07 chore(slim-jim) add configuration 2012-02-21 22:45:58 -08:00
Misko Hevery
0f6b2ef982 refactor(sanitizer): turn sanitizer into a service 2012-01-25 11:46:35 -08:00
Vojta Jina
dbffbefb7c refactor($controller): Add $controller service for instantiating controllers
So that we can allow user to override this service and use BC hack:
https://gist.github.com/1649788
2012-01-23 13:11:12 -08:00
Vojta Jina
15fd735793 refactor($autoScroll): rename to $anchorScroll and allow disabling auto scrolling (links)
Now, that we have autoscroll attribute on ng:include, there is no reason to disable the service completely, so $anchorScrollProvider.disableAutoScrolling() means it won't be scrolling when $location.hash() changes.

And then, it's not $autoScroll at all, it actually scrolls to anchor when it's called, so I renamed
it to $anchorScroll.
2012-01-13 01:07:12 -08:00
Misko Hevery
5143e7bf06 feat(module): new module loader 2012-01-10 22:27:00 -08:00
Igor Minar
9632f5c1c7 style(q): rename src/Deferred.js to src/service/q.js 2012-01-03 17:48:09 -08:00
Misko Hevery
0e1fa2aefe feat($interpolate): string interpolation function 2011-11-30 14:49:36 -05:00
Igor Minar
1cdfa3b960 feat(deferreds/promises): Q-like deferred/promise implementation with a ton of specs 2011-11-30 14:49:03 -05:00