a b/.eggs/bleach-3.1.0-py3.6.egg/EGG-INFO/PKG-INFO
1
Metadata-Version: 2.0
2
Name: bleach
3
Version: 3.1.0
4
Summary: An easy safelist-based HTML-sanitizing tool.
5
Home-page: https://github.com/mozilla/bleach
6
Author: Will Kahn-Greene
7
Author-email: willkg@mozilla.com
8
License: Apache Software License
9
Description-Content-Type: UNKNOWN
10
Platform: UNKNOWN
11
Classifier: Development Status :: 5 - Production/Stable
12
Classifier: Environment :: Web Environment
13
Classifier: Intended Audience :: Developers
14
Classifier: License :: OSI Approved :: Apache Software License
15
Classifier: Operating System :: OS Independent
16
Classifier: Programming Language :: Python
17
Classifier: Programming Language :: Python :: 2
18
Classifier: Programming Language :: Python :: 2.7
19
Classifier: Programming Language :: Python :: 3
20
Classifier: Programming Language :: Python :: 3.4
21
Classifier: Programming Language :: Python :: 3.5
22
Classifier: Programming Language :: Python :: 3.6
23
Classifier: Programming Language :: Python :: 3.7
24
Classifier: Programming Language :: Python :: Implementation :: CPython
25
Classifier: Programming Language :: Python :: Implementation :: PyPy
26
Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
28
Requires-Dist: six (>=1.9.0)
29
Requires-Dist: webencodings
30
31
======
32
Bleach
33
======
34
35
.. image:: https://travis-ci.org/mozilla/bleach.svg?branch=master
36
   :target: https://travis-ci.org/mozilla/bleach
37
38
.. image:: https://badge.fury.io/py/bleach.svg
39
   :target: http://badge.fury.io/py/bleach
40
41
Bleach is an allowed-list-based HTML sanitizing library that escapes or strips
42
markup and attributes.
43
44
Bleach can also linkify text safely, applying filters that Django's ``urlize``
45
filter cannot, and optionally setting ``rel`` attributes, even on links already
46
in the text.
47
48
Bleach is intended for sanitizing text from *untrusted* sources. If you find
49
yourself jumping through hoops to allow your site administrators to do lots of
50
things, you're probably outside the use cases. Either trust those users, or
51
don't.
52
53
Because it relies on html5lib_, Bleach is as good as modern browsers at dealing
54
with weird, quirky HTML fragments. And *any* of Bleach's methods will fix
55
unbalanced or mis-nested tags.
56
57
The version on GitHub_ is the most up-to-date and contains the latest bug
58
fixes. You can find full documentation on `ReadTheDocs`_.
59
60
:Code:           https://github.com/mozilla/bleach
61
:Documentation:  https://bleach.readthedocs.io/
62
:Issue tracker:  https://github.com/mozilla/bleach/issues
63
:IRC:            ``#bleach`` on irc.mozilla.org
64
:License:        Apache License v2; see LICENSE file
65
66
67
Reporting Bugs
68
==============
69
70
For regular bugs, please report them `in our issue tracker
71
<https://github.com/mozilla/bleach/issues>`_.
72
73
If you believe that you've found a security vulnerability, please `file a secure
74
bug report in our bug tracker
75
<https://bugzilla.mozilla.org/enter_bug.cgi?assigned_to=nobody%40mozilla.org&product=Webtools&component=Bleach-security&groups=webtools-security>`_
76
or send an email to *security AT mozilla DOT org*.
77
78
For more information on security-related bug disclosure and the PGP key to use
79
for sending encrypted mail or to verify responses received from that address,
80
please read our wiki page at
81
`<https://www.mozilla.org/en-US/security/#For_Developers>`_.
82
83
84
Security
85
========
86
87
Bleach is a security-focused library.
88
89
We have a responsible security vulnerability reporting process. Please use
90
that if you're reporting a security issue.
91
92
Security issues are fixed in private. After we land such a fix, we'll do a
93
release.
94
95
For every release, we mark security issues we've fixed in the ``CHANGES`` in
96
the **Security issues** section. We include any relevant CVE links.
97
98
99
Installing Bleach
100
=================
101
102
Bleach is available on PyPI_, so you can install it with ``pip``::
103
104
    $ pip install bleach
105
106
107
Upgrading Bleach
108
================
109
110
.. warning::
111
112
   Before doing any upgrades, read through `Bleach Changes
113
   <https://bleach.readthedocs.io/en/latest/changes.html>`_ for backwards
114
   incompatible changes, newer versions, etc.
115
116
117
Basic use
118
=========
119
120
The simplest way to use Bleach is:
121
122
.. code-block:: python
123
124
    >>> import bleach
125
126
    >>> bleach.clean('an <script>evil()</script> example')
127
    u'an &lt;script&gt;evil()&lt;/script&gt; example'
128
129
    >>> bleach.linkify('an http://example.com url')
130
    u'an <a href="http://example.com" rel="nofollow">http://example.com</a> url
131
132
133
Code of conduct
134
===============
135
136
This project and repository is governed by Mozilla's code of conduct and
137
etiquette guidelines. For more details please see the `Mozilla Community
138
Participation Guidelines
139
<https://www.mozilla.org/about/governance/policies/participation/>`_ and
140
`Developer Etiquette Guidelines
141
<https://bugzilla.mozilla.org/page.cgi?id=etiquette.html>`_.
142
143
144
.. _html5lib: https://github.com/html5lib/html5lib-python
145
.. _GitHub: https://github.com/mozilla/bleach
146
.. _ReadTheDocs: https://bleach.readthedocs.io/
147
.. _PyPI: http://pypi.python.org/pypi/bleach
148
149
150
Bleach changes
151
==============
152
153
Version 3.1.0 (January 9th, 2019)
154
---------------------------------
155
156
**Security fixes**
157
158
None
159
160
**Backwards incompatible changes**
161
162
None
163
164
**Features**
165
166
* Add ``recognized_tags`` argument to the linkify ``Linker`` class. This
167
  fixes issues when linkifying on its own and having some tags get escaped.
168
  It defaults to a list of HTML5 tags. Thank you, Chad Birch! (#409)
169
170
**Bug fixes**
171
172
* Add ``six>=1.9`` to requirements. Thank you, Dave Shawley (#416)
173
174
* Fix cases where attribute names could have invalid characters in them.
175
  (#419)
176
177
* Fix problems with ``LinkifyFilter`` not being able to match links
178
  across ``&amp;``. (#422)
179
180
* Fix ``InputStreamWithMemory`` when the ``BleachHTMLParser`` is
181
  parsing ``meta`` tags. (#431)
182
183
* Fix doctests. (#357)
184
185
186
Version 3.0.2 (October 11th, 2018)
187
----------------------------------
188
189
**Security fixes**
190
191
None
192
193
**Backwards incompatible changes**
194
195
None
196
197
**Features**
198
199
None
200
201
**Bug fixes**
202
203
* Merge ``Characters`` tokens after sanitizing them. This fixes issues in the
204
  ``LinkifyFilter`` where it was only linkifying parts of urls. (#374)
205
206
207
Version 3.0.1 (October 9th, 2018)
208
---------------------------------
209
210
**Security fixes**
211
212
None
213
214
**Backwards incompatible changes**
215
216
None
217
218
**Features**
219
220
* Support Python 3.7. It supported Python 3.7 just fine, but we added 3.7 to
221
  the list of Python environments we test so this is now officially supported.
222
  (#377)
223
224
**Bug fixes**
225
226
* Fix ``list`` object has no attribute ``lower`` in ``clean``. (#398)
227
* Fix ``abbr`` getting escaped in ``linkify``. (#400)
228
229
230
Version 3.0.0 (October 3rd, 2018)
231
---------------------------------
232
233
**Security fixes**
234
235
None
236
237
**Backwards incompatible changes**
238
239
* A bunch of functions were moved from one module to another.
240
241
  These were moved from ``bleach.sanitizer`` to ``bleach.html5lib_shim``:
242
243
  * ``convert_entity``
244
  * ``convert_entities``
245
  * ``match_entity``
246
  * ``next_possible_entity``
247
  * ``BleachHTMLSerializer``
248
  * ``BleachHTMLTokenizer``
249
  * ``BleachHTMLParser``
250
251
  These functions and classes weren't documented and aren't part of the
252
  public API, but people read code and might be using them so we're
253
  considering it an incompatible API change.
254
255
  If you're using them, you'll need to update your code.
256
257
**Features**
258
259
* Bleach no longer depends on html5lib. html5lib==1.0.1 is now vendored into
260
  Bleach. You can remove it from your requirements file if none of your other
261
  requirements require html5lib.
262
263
  This means Bleach will now work fine with other libraries that depend on
264
  html5lib regardless of what version of html5lib they require. (#386)
265
266
**Bug fixes**
267
268
* Fixed tags getting added when using clean or linkify. This was a
269
  long-standing regression from the Bleach 2.0 rewrite. (#280, #392)
270
271
* Fixed ``<isindex>`` getting replaced with a string. Now it gets escaped or
272
  stripped depending on whether it's in the allowed tags or not. (#279)
273
274
275
Version 2.1.4 (August 16th, 2018)
276
---------------------------------
277
278
**Security fixes**
279
280
None
281
282
**Backwards incompatible changes**
283
284
* Dropped support for Python 3.3. (#328)
285
286
**Features**
287
288
None
289
290
**Bug fixes**
291
292
* Handle ambiguous ampersands in correctly. (#359)
293
294
295
Version 2.1.3 (March 5th, 2018)
296
-------------------------------
297
298
**Security fixes**
299
300
* Attributes that have URI values weren't properly sanitized if the
301
  values contained character entities. Using character entities, it
302
  was possible to construct a URI value with a scheme that was not
303
  allowed that would slide through unsanitized.
304
305
  This security issue was introduced in Bleach 2.1. Anyone using
306
  Bleach 2.1 is highly encouraged to upgrade.
307
308
  https://bugzilla.mozilla.org/show_bug.cgi?id=1442745
309
310
**Backwards incompatible changes**
311
312
None
313
314
**Features**
315
316
None
317
318
**Bug fixes**
319
320
* Fixed some other edge cases for attribute URI value sanitizing and
321
  improved testing of this code.
322
323
324
Version 2.1.2 (December 7th, 2017)
325
----------------------------------
326
327
**Security fixes**
328
329
None
330
331
**Backwards incompatible changes**
332
333
None
334
335
**Features**
336
337
None
338
339
**Bug fixes**
340
341
* Support html5lib-python 1.0.1. (#337)
342
343
* Add deprecation warning for supporting html5lib-python < 1.0.
344
345
* Switch to semver.
346
347
348
Version 2.1.1 (October 2nd, 2017)
349
---------------------------------
350
351
**Security fixes**
352
353
None
354
355
**Backwards incompatible changes**
356
357
None
358
359
**Features**
360
361
None
362
363
**Bug fixes**
364
365
* Fix ``setup.py`` opening files when ``LANG=``. (#324)
366
367
368
Version 2.1 (September 28th, 2017)
369
----------------------------------
370
371
**Security fixes**
372
373
* Convert control characters (backspace particularly) to "?" preventing
374
  malicious copy-and-paste situations. (#298)
375
376
  See `<https://github.com/mozilla/bleach/issues/298>`_ for more details.
377
378
  This affects all previous versions of Bleach. Check the comments on that
379
  issue for ways to alleviate the issue if you can't upgrade to Bleach 2.1.
380
381
382
**Backwards incompatible changes**
383
384
* Redid versioning. ``bleach.VERSION`` is no longer available. Use the string
385
  version at ``bleach.__version__`` and parse it with
386
  ``pkg_resources.parse_version``. (#307)
387
388
* clean, linkify: linkify and clean should only accept text types; thank you,
389
  Janusz! (#292)
390
391
* clean, linkify: accept only unicode or utf-8-encoded str (#176)
392
393
394
**Features**
395
396
397
**Bug fixes**
398
399
* ``bleach.clean()`` no longer unescapes entities including ones that are missing
400
  a ``;`` at the end which can happen in urls and other places. (#143)
401
402
* linkify: fix http links inside of mailto links; thank you, sedrubal! (#300)
403
404
* clarify security policy in docs (#303)
405
406
* fix dependency specification for html5lib 1.0b8, 1.0b9, and 1.0b10; thank you,
407
  Zoltán! (#268)
408
409
* add Bleach vs. html5lib comparison to README; thank you, Stu Cox! (#278)
410
411
* fix KeyError exceptions on tags without href attr; thank you, Alex Defsen!
412
  (#273)
413
414
* add test website and scripts to test ``bleach.clean()`` output in browser;
415
  thank you, Greg Guthe!
416
417
418
Version 2.0 (March 8th, 2017)
419
-----------------------------
420
421
**Security fixes**
422
423
* None
424
425
426
**Backwards incompatible changes**
427
428
* Removed support for Python 2.6. #206
429
430
* Removed support for Python 3.2. #224
431
432
* Bleach no longer supports html5lib < 0.99999999 (8 9s).
433
434
  This version is a rewrite to use the new sanitizing API since the old
435
  one was dropped in html5lib 0.99999999 (8 9s).
436
437
  If you're using 0.9999999 (7 9s) upgrade to 0.99999999 (8 9s) or higher.
438
439
  If you're using 1.0b8 (equivalent to 0.9999999 (7 9s)), upgrade to 1.0b9
440
  (equivalent to 0.99999999 (8 9s)) or higher.
441
442
* ``bleach.clean`` and friends were rewritten
443
444
  ``clean`` was reimplemented as an html5lib filter and happens at a different
445
  step in the HTML parsing -> traversing -> serializing process. Because of
446
  that, there are some differences in clean's output as compared with previous
447
  versions.
448
449
  Amongst other things, this version will add end tags even if the tag in
450
  question is to be escaped.
451
452
* ``bleach.clean`` and friends attribute callables now take three arguments:
453
  tag, attribute name and attribute value. Previously they only took attribute
454
  name and attribute value.
455
456
  All attribute callables will need to be updated.
457
458
* ``bleach.linkify`` was rewritten
459
460
  ``linkify`` was reimplemented as an html5lib Filter. As such, it no longer
461
  accepts a ``tokenizer`` argument.
462
463
  The callback functions for adjusting link attributes now takes a namespaced
464
  attribute.
465
466
  Previously you'd do something like this::
467
468
      def check_protocol(attrs, is_new):
469
          if not attrs.get('href', '').startswith('http:', 'https:')):
470
              return None
471
          return attrs
472
473
  Now it's more like this::
474
475
      def check_protocol(attrs, is_new):
476
          if not attrs.get((None, u'href'), u'').startswith(('http:', 'https:')):
477
              #            ^^^^^^^^^^^^^^^
478
              return None
479
          return attrs
480
481
  Further, you need to make sure you're always using unicode values. If you
482
  don't then html5lib will raise an assertion error that the value is not
483
  unicode.
484
485
  All linkify filters will need to be updated.
486
487
* ``bleach.linkify`` and friends had a ``skip_pre`` argument--that's been
488
  replaced with a more general ``skip_tags`` argument.
489
490
  Before, you might do::
491
492
      bleach.linkify(some_text, skip_pre=True)
493
494
  The equivalent with Bleach 2.0 is::
495
496
      bleach.linkify(some_text, skip_tags=['pre'])
497
498
  You can skip other tags, too, like ``style`` or ``script`` or other places
499
  where you don't want linkification happening.
500
501
  All uses of linkify that use ``skip_pre`` will need to be updated.
502
503
504
**Changes**
505
506
* Supports Python 3.6.
507
508
* Supports html5lib >= 0.99999999 (8 9s).
509
510
* There's a ``bleach.sanitizer.Cleaner`` class that you can instantiate with your
511
  favorite clean settings for easy reuse.
512
513
* There's a ``bleach.linkifier.Linker`` class that you can instantiate with your
514
  favorite linkify settings for easy reuse.
515
516
* There's a ``bleach.linkifier.LinkifyFilter`` which is an htm5lib filter that
517
  you can pass as a filter to ``bleach.sanitizer.Cleaner`` allowing you to clean
518
  and linkify in one pass.
519
520
* ``bleach.clean`` and friends can now take a callable as an attributes arg value.
521
522
* Tons of bug fixes.
523
524
* Cleaned up tests.
525
526
* Documentation fixes.
527
528
529
Version 1.5 (November 4th, 2016)
530
--------------------------------
531
532
**Security fixes**
533
534
* None
535
536
**Backwards incompatible changes**
537
538
* clean: The list of ``ALLOWED_PROTOCOLS`` now defaults to http, https and
539
  mailto.
540
541
  Previously it was a long list of protocols something like ed2k, ftp, http,
542
  https, irc, mailto, news, gopher, nntp, telnet, webcal, xmpp, callto, feed,
543
  urn, aim, rsync, tag, ssh, sftp, rtsp, afs, data. #149
544
545
**Changes**
546
547
* clean: Added ``protocols`` to arguments list to let you override the list of
548
  allowed protocols. Thank you, Andreas Malecki! #149
549
550
* linkify: Fix a bug involving periods at the end of an email address. Thank you,
551
  Lorenz Schori! #219
552
553
* linkify: Fix linkification of non-ascii ports. Thank you Alexandre, Macabies!
554
  #207
555
556
* linkify: Fix linkify inappropriately removing node tails when dropping nodes.
557
  #132
558
559
* Fixed a test that failed periodically. #161
560
561
* Switched from nose to py.test. #204
562
563
* Add test matrix for all supported Python and html5lib versions. #230
564
565
* Limit to html5lib ``>=0.999,!=0.9999,!=0.99999,<0.99999999`` because 0.9999
566
  and 0.99999 are busted.
567
568
* Add support for ``python setup.py test``. #97
569
570
571
Version 1.4.3 (May 23rd, 2016)
572
------------------------------
573
574
**Security fixes**
575
576
* None
577
578
**Changes**
579
580
* Limit to html5lib ``>=0.999,<0.99999999`` because of impending change to
581
  sanitizer api. #195
582
583
584
Version 1.4.2 (September 11, 2015)
585
----------------------------------
586
587
**Changes**
588
589
* linkify: Fix hang in linkify with ``parse_email=True``. #124
590
591
* linkify: Fix crash in linkify when removing a link that is a first-child. #136
592
593
* Updated TLDs.
594
595
* linkify: Don't remove exterior brackets when linkifying. #146
596
597
598
Version 1.4.1 (December 15, 2014)
599
---------------------------------
600
601
**Changes**
602
603
* Consistent order of attributes in output.
604
605
* Python 3.4 support.
606
607
608
Version 1.4 (January 12, 2014)
609
------------------------------
610
611
**Changes**
612
613
* linkify: Update linkify to use etree type Treewalker instead of simpletree.
614
615
* Updated html5lib to version ``>=0.999``.
616
617
* Update all code to be compatible with Python 3 and 2 using six.
618
619
* Switch to Apache License.
620
621
622
Version 1.3
623
-----------
624
625
* Used by Python 3-only fork.
626
627
628
Version 1.2.2 (May 18, 2013)
629
----------------------------
630
631
* Pin html5lib to version 0.95 for now due to major API break.
632
633
634
Version 1.2.1 (February 19, 2013)
635
---------------------------------
636
637
* ``clean()`` no longer considers ``feed:`` an acceptable protocol due to
638
  inconsistencies in browser behavior.
639
640
641
Version 1.2 (January 28, 2013)
642
------------------------------
643
644
* ``linkify()`` has changed considerably. Many keyword arguments have been
645
  replaced with a single callbacks list. Please see the documentation for more
646
  information.
647
648
* Bleach will no longer consider unacceptable protocols when linkifying.
649
650
* ``linkify()`` now takes a tokenizer argument that allows it to skip
651
  sanitization.
652
653
* ``delinkify()`` is gone.
654
655
* Removed exception handling from ``_render``. ``clean()`` and ``linkify()`` may
656
  now throw.
657
658
* ``linkify()`` correctly ignores case for protocols and domain names.
659
660
* ``linkify()`` correctly handles markup within an <a> tag.
661
662
663
Version 1.1.5
664
-------------
665
666
667
Version 1.1.4
668
-------------
669
670
671
Version 1.1.3 (July 10, 2012)
672
-----------------------------
673
674
* Fix parsing bare URLs when parse_email=True.
675
676
677
Version 1.1.2 (June 1, 2012)
678
----------------------------
679
680
* Fix hang in style attribute sanitizer. (#61)
681
682
* Allow ``/`` in style attribute values.
683
684
685
Version 1.1.1 (February 17, 2012)
686
---------------------------------
687
688
* Fix tokenizer for html5lib 0.9.5.
689
690
691
Version 1.1.0 (October 24, 2011)
692
--------------------------------
693
694
* ``linkify()`` now understands port numbers. (#38)
695
696
* Documented character encoding behavior. (#41)
697
698
* Add an optional target argument to ``linkify()``.
699
700
* Add ``delinkify()`` method. (#45)
701
702
* Support subdomain whitelist for ``delinkify()``. (#47, #48)
703
704
705
Version 1.0.4 (September 2, 2011)
706
---------------------------------
707
708
* Switch to SemVer git tags.
709
710
* Make ``linkify()`` smarter about trailing punctuation. (#30)
711
712
* Pass ``exc_info`` to logger during rendering issues.
713
714
* Add wildcard key for attributes. (#19)
715
716
* Make ``linkify()`` use the ``HTMLSanitizer`` tokenizer. (#36)
717
718
* Fix URLs wrapped in parentheses. (#23)
719
720
* Make ``linkify()`` UTF-8 safe. (#33)
721
722
723
Version 1.0.3 (June 14, 2011)
724
-----------------------------
725
726
* ``linkify()`` works with 3rd level domains. (#24)
727
728
* ``clean()`` supports vendor prefixes in style values. (#31, #32)
729
730
* Fix ``linkify()`` email escaping.
731
732
733
Version 1.0.2 (June 6, 2011)
734
----------------------------
735
736
* ``linkify()`` supports email addresses.
737
738
* ``clean()`` supports callables in attributes filter.
739
740
741
Version 1.0.1 (April 12, 2011)
742
------------------------------
743
744
* ``linkify()`` doesn't drop trailing slashes. (#21)
745
* ``linkify()`` won't linkify 'libgl.so.1'. (#22)
746
747