==========================Django 1.6.3 release notes==========================*April 21, 2014*Django 1.6.3 fixes several bugs in 1.6.2, including three security issues,and makes one backwards-incompatible change:Unexpected code execution using ``reverse()``=============================================Django's URL handling is based on a mapping of regex patterns(representing the URLs) to callable views, and Django's own processingconsists of matching a requested URL against those patterns todetermine the appropriate view to invoke.Django also provides a convenience function -- ``reverse()`` -- which performsthis process in the opposite direction. The ``reverse()`` function takesinformation about a view and returns a URL which would invoke that view. Useof ``reverse()`` is encouraged for application developers, as the output of``reverse()`` is always based on the current URL patterns, meaning developersdo not need to change other code when making changes to URLs.One argument signature for ``reverse()`` is to pass a dotted Pythonpath to the desired view. In this situation, Django will import themodule indicated by that dotted path as part of generating theresulting URL. If such a module has import-time side effects, thoseside effects will occur.Thus it is possible for an attacker to cause unexpected codeexecution, given the following conditions:1. One or more views are present which construct a URL based on userinput (commonly, a "next" parameter in a querystring indicatingwhere to redirect upon successful completion of an action).2. One or more modules are known to an attacker to exist on theserver's Python import path, which perform code execution with sideeffects on importing.To remedy this, ``reverse()`` will now only accept and import dottedpaths based on the view-containing modules listed in the project's :doc:`URLpattern configuration </topics/http/urls>`, so as to ensure that only modulesthe developer intended to be imported in this fashion can or will be imported.Caching of anonymous pages could reveal CSRF token==================================================Django includes both a :doc:`caching framework </topics/cache>` and a systemfor :doc:`preventing cross-site request forgery (CSRF) attacks</ref/csrf/>`. The CSRF-protection system is based on a random noncesent to the client in a cookie which must be sent by the client on futurerequests and, in forms, a hidden value which must be submitted back with theform.The caching framework includes an option to cache responses toanonymous (i.e., unauthenticated) clients.When the first anonymous request to a given page is by a client whichdid not have a CSRF cookie, the cache framework will also cache theCSRF cookie and serve the same nonce to other anonymous clients whodo not have a CSRF cookie. This can allow an attacker to obtain avalid CSRF cookie value and perform attacks which bypass the check forthe cookie.To remedy this, the caching framework will no longer cache suchresponses. The heuristic for this will be:1. If the incoming request did not submit any cookies, and2. If the response did send one or more cookies, and3. If the ``Vary: Cookie`` header is set on the response, then theresponse will not be cached.MySQL typecasting=================The MySQL database is known to "typecast" on certain queries; forexample, when querying a table which contains string values, but usinga query which filters based on an integer value, MySQL will firstsilently coerce the strings to integers and return a result based on that.If a query is performed without first converting values to theappropriate type, this can produce unexpected results, similar to whatwould occur if the query itself had been manipulated.Django's model field classes are aware of their own types and mostsuch classes perform explicit conversion of query arguments to thecorrect database-level type before querying. However, three modelfield classes did not correctly convert their arguments:* :class:`~django.db.models.FilePathField`* :class:`~django.db.models.GenericIPAddressField`* ``IPAddressField``These three fields have been updated to convert their arguments to thecorrect types before querying.Additionally, developers of custom model fields are now warned viadocumentation to ensure their custom field classes will performappropriate type conversions, and users of the :meth:`raw()<django.db.models.query.QuerySet.raw>` and :meth:`extra()<django.db.models.query.QuerySet.extra>` query methods -- which allow thedeveloper to supply raw SQL or SQL fragments -- will be advised to ensure theyperform appropriate manual type conversions prior to executing queries.``select_for_update()`` requires a transaction==============================================Historically, queries that use:meth:`~django.db.models.query.QuerySet.select_for_update()` could beexecuted in autocommit mode, outside of a transaction. Before Django1.6, Django's automatic transactions mode allowed this to be used tolock records until the next write operation. Django 1.6 introduceddatabase-level autocommit; since then, execution in such a contextvoids the effect of ``select_for_update()``. It is, therefore, assumednow to be an error and raises an exception.This change was made because such errors can be caused by including anapp which expects global transactions (e.g. :setting:`ATOMIC_REQUESTS<DATABASE-ATOMIC_REQUESTS>` set to ``True``), or Django's old autocommitbehavior, in a project which runs without them; and further, sucherrors may manifest as data-corruption bugs.This change may cause test failures if you use ``select_for_update()``in a test class which is a subclass of:class:`~django.test.TransactionTestCase` rather than:class:`~django.test.TestCase`.Other bugfixes and changes==========================* Content retrieved from the GeoIP library is now properly decoded from itsdefault ``iso-8859-1`` encoding(:ticket:`21996`).* Fixed ``AttributeError`` when using:meth:`~django.db.models.query.QuerySet.bulk_create` with ``ForeignObject``(:ticket:`21566`).* Fixed crash of ``QuerySet``\s that use ``F() + timedelta()`` when their querywas compiled more once(:ticket:`21643`).* Prevented custom ``widget`` class attribute of:class:`~django.forms.IntegerField` subclasses from being overwritten by thecode in their ``__init__`` method(:ticket:`22245`).* Improved :func:`~django.utils.html.strip_tags` accuracy (but it still cannotguarantee an HTML-safe result, as stated in the documentation).* Fixed a regression in the :mod:`django.contrib.gis` SQL compiler fornon-concrete fields (:ticket:`22250`).* Fixed :attr:`ModelAdmin.preserve_filters<django.contrib.admin.ModelAdmin.preserve_filters>` when running a site witha URL prefix (:ticket:`21795`).* Fixed a crash in the ``find_command`` management utility when the ``PATH``environment variable wasn't set(:ticket:`22256`).* Fixed :djadmin:`changepassword` on Windows(:ticket:`22364`).* Avoided shadowing deadlock exceptions on MySQL(:ticket:`22291`).* Wrapped database exceptions in ``_set_autocommit``(:ticket:`22321`).* Fixed atomicity when closing a database connection or when the database serverdisconnects (:ticket:`21239` and :ticket:`21202`)* Fixed regression in ``prefetch_related`` that caused the related objectsquery to include an unnecessary join(:ticket:`21760`).Additionally, Django's vendored version of six, ``django.utils.six`` has beenupgraded to the latest release (1.6.1).