Questions tagged [bleach]

Bleach is a whitelist-based HTML sanitizing Python library that escapes or strips markup and attributes.

18 questions
4
votes
1 answer

Make Bleach to allow code tags

I'm trying to use bleach to escape HTML tags. It works just fine, unless I'm trying to insert a code snipped as a content of a page. The snippet is inserted like this:

 Code sample

The code sample may contain html tags.…
Ivan
  • 609
  • 8
  • 21
2
votes
1 answer

bleach stripping style that should be allowed

I have the following string: html = '
2
votes
1 answer

python bleach: inconsistent cleaning behaviour

I would like to use bleach to format some potentially unclean HTML. In the following sample, ideally bleach should remove: the extra spaces in the first opening

the attribute in the closing link tag the extra spaces in the…

lhk
  • 27,458
  • 30
  • 122
  • 201
2
votes
0 answers

Bleach and html5lib incompatible with tensorboard

While installing tensorflow I received the following error : distributed 1.21.8 requires msgpack, which is not installed. which I tried resolving by executing the following command conda install -c anaconda msgpack-python pip install…
Bi613
  • 121
  • 1
  • 1
  • 5
2
votes
1 answer

Bleach: How to add nofollow attribute to existing links?

I am aware that it is possible to linkify URLs that have not yet become html links, and Bleach will automatically add rel="nofollow". (Source: http://bleach.readthedocs.io/en/latest/linkify.html) But how do I add the nofollow attribute to URLs that…
Flux
  • 9,805
  • 5
  • 46
  • 92
1
vote
0 answers

Prevent pip from upgrading a dependency

I have a website based off Mezzanine of which Bleach is installed as a dependency. Bleach 2.0 is incompatible with my version of Mezzanine. I tried specifying Bleach's version as ==1.5 in my requirements.txt file but every pip install still upgrades…
stakolee
  • 893
  • 1
  • 7
  • 20
1
vote
1 answer

Process fields in SQLAlchemy model (using flask_sqlalchemy)

I am using SQLAlchemy through flask_sqlalchemy. A model receives input from HTML forms. I would like this input to be stripped of any tags. Instead of doing this several times in the code before assignment, I thought it might be better to implement…
user52366
  • 1,035
  • 1
  • 10
  • 21
0
votes
0 answers

Django Bleach with CKeditor?

Good morning, have you already configured Django Bleach for CKEDITOR? Actually I'm using a form with Django. And I use CKEDITOR to be able to write. But is there a configuration to use Django Bleach with? Because in my template I use |safe. THANKS I…
0
votes
1 answer

BLEACH_DEFAULT_WIDGET django

I have django-bleach in my project. In models use: class Post(models.Model): title = models.CharField(max_length=255) content_2 = HTMLField() In settings.py: BLEACH_DEFAULT_WIDGET = 'wysiwyg.widgets.WysiwygWidget' How to write the…
Sergey Ka
  • 25
  • 9
0
votes
1 answer

timyMCE allowed tags in django

In django I am using tinyMCE field for admin. I need to add a set of tags allowed by me, how can I do this? 'paste_as_text': True, not suitable, need to write a list and make it universally
Sergey Ka
  • 25
  • 9
0
votes
1 answer

How to remove links from HTML completely with Bleach?

Bleach strips non-whitelisted tags from HTML, but leaves child nodes, e.g. >>> import bleach >>> bleach.clean("stays", strip=True, tags=[]) 'stays' >>> How can the entire element along with its children be removed?
handle
  • 5,859
  • 3
  • 54
  • 82
0
votes
1 answer

Python Bleach: is there any way to strip tags that are disallowed rather than allowed?

I am aware that Bleach takes a list of ALLOWED_TAGS and strips out any tags not in that list when performing clean(). Is there a way to flip that around and strip tags based on those that are defined as disallowed? In other words, start by assuming…
alstr
  • 1,358
  • 18
  • 34
0
votes
0 answers

ERROR: Could not find a version that satisfies the requirement bleach==2.1.2 (from -r requirements.txt (line 1)) (from versions: none)

"pip install -r requirements.txt" is the command which gives the error that couldnot find version that satisfies the requirement bleach."requirements.txt" is a file which has all the python packages to be installed.The question is how to resolve the…
0
votes
1 answer

bleach clean adds "
“ tag at the beginning rather than cleaning

I scraped some html contents from internet, below is only a beginning part of it,

X.C.
  • 703
  • 9
  • 18
0
votes
1 answer

Sanitise HTML content with Python

I am working with an external API which is sending me text from HTML emails. The text comes through without the HTML structure (e.g. ... etc). I need to sanitise this text and output to Slack. I have tried using BeautifulSoup and…
btongeorge
  • 421
  • 2
  • 12
  • 23
1
2