Skip to content

Tags: feicc/bleach

Tags

v2.0

Toggle v2.0's commit message
Version 2.0 (March 8th, 2017)

-----------------------------

**Backwards incompatible changes**

* Removed support for Python 2.6. mozilla#206

* Removed support for Python 3.2. mozilla#224

* Bleach no longer supports html5lib < 0.99999999 (8 9s).

  This version is a rewrite to use the new sanitizing API since the old
  one was dropped in html5lib 0.99999999 (8 9s).

* ``bleach.clean`` and friends were rewritten

  ``clean`` was reimplemented as an html5lib filter and happens at a different
  step in the HTML parsing -> traversing -> serializing process. Because of
  that, there are some differences in clean's output as compared with previous
  versions.

  Amongst other things, this version will add end tags even if the tag in
  question is to be escaped.

* ``bleach.clean`` and friends attribute callables now take three arguments:
  tag, attribute name and attribute value. Previously they only took attribute
  name and attribute value.

  All attribute callables will need to be updated.

* ``bleach.linkify`` was rewritten

  ``linkify`` was reimplemented as an html5lib Filter. As such, it no longer
  accepts a ``tokenizer`` argument.

  The callback functions for adjusting link attributes now takes a namespaced
  attribute.

  Previously you'd do something like this::

      def check_protocol(attrs, is_new):
          if not attrs.get('href', '').startswith('http:', 'https:')):
              return None
          return attrs

  Now it's more like this::

      def check_protocol(attrs, is_new):
          if not attrs.get((None, u'href'), u'').startswith(('http:', 'https:')):
              #            ^^^^^^^^^^^^^^^
              return None
          return attrs

  Further, you need to make sure you're always using unicode values. If you
  don't then html5lib will raise an assertion error that the value is not
  unicode.

  All linkify filters will need to be updated.

* ``bleach.linkify`` and friends had a ``skip_pre`` argument--that's been
  replaced with a more general ``skip_tags`` argument.

  Before, you might do::

      bleach.linkify(some_text, skip_pre=True)

  The equivalent with Bleach 2.0 is::

      bleach.linkify(some_text, skip_tags=['pre'])

  You can skip other tags, too, like ``style`` or ``script`` or other places
  where you don't want linkification happening.

  All uses of linkify that use ``skip_pre`` will need to be updated.

**Changes**

* Supports Python 3.6.

* Supports html5lib >= 0.99999999 (8 9s).

* There's a ``bleach.sanitizer.Cleaner`` class that you can instantiate with your
  favorite clean settings for easy reuse.

* There's a ``bleach.linkifier.Linker`` class that you can instantiate with your
  favorite linkify settings for easy reuse.

* There's a ``bleach.linkifier.LinkifyFilter`` which is an htm5lib filter that
  you can pass as a filter to ``bleach.sanitizer.Cleaner`` allowing you to clean
  and linkify in one pass.

* ``bleach.clean`` and friends can now take a callable as an attributes arg value.

* Tons of bug fixes.

* Cleaned up tests.

* Documentation fixes.

v1.5

Toggle v1.5's commit message
Version 1.5 (November 4th, 2016)

--------------------------------

**Backwards incompatible changes**

- clean: The list of ``ALLOWED_PROTOCOLS`` now defaults to http, https
  and mailto. Previously it was a long list of protocols something like
  ed2k, ftp, http, https, irc, mailto, news, gopher, nntp, telnet,
  webcal, xmpp, callto, feed, urn, aim, rsync, tag, ssh, sftp, rtsp,
  afs, data. mozilla#149

**Changes**

- clean: Added ``protocols`` to arguments list to let you override the
  list of allowed protocols. Thank you, Andreas Malecki! mozilla#149
- linkify: Fix a bug involving periods at the end of an email address.
  Thank you, Lorenz Schori! mozilla#219
- linkify: Fix linkification of non-ascii ports. Thank you Alexandre,
  Macabies! mozilla#207
- linkify: Fix linkify inappropriately removing node tails when dropping
  nodes. mozilla#132
- Fixed a test that failed periodically. mozilla#161
- Switched from nose to py.test. mozilla#204
- Add test matrix for all supported Python and html5lib versions. mozilla#230
- Limit to html5lib ``>=0.999,!=0.9999,!=0.99999,<0.99999999`` because
  ``0.9999`` and ``0.99999`` are busted.
- Add support for ``python setup.py test``. mozilla#97

v1.4.3

Toggle v1.4.3's commit message
Version 1.4.3

- Limit to html5lib >=0.999<0.99999999 because of impending change to
  sanitizer api. mozilla#195

v1.4.2

Toggle v1.4.2's commit message
Version 1.4.2.

v1.4.1

Toggle v1.4.1's commit message
Version 1.4.1.

v1.4

Toggle v1.4's commit message
Version 1.4.

v1.2.2

Toggle v1.2.2's commit message
Pin html5lib==0.9.5 for now.

Addresses mozilla#94 but doesn't fix it. Will need to look into replacing
simpletree.

- Pin requirements file.
- Pin setup.py requirements.
- Add note to docs.

v1.2.1

Toggle v1.2.1's commit message
Version bump v1.2.1 and changelog.

v1.2

Toggle v1.2's commit message
Version bump to 1.2.

v1.1.5

Toggle v1.1.5's commit message
Version bump for a couple of changes.