Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Code getting removed. #25

Closed
astikanand opened this issue Mar 17, 2018 · 10 comments
Closed

HTML Code getting removed. #25

astikanand opened this issue Mar 17, 2018 · 10 comments

Comments

@astikanand
Copy link

Whenever any HTML Code is written inside the editor it is being removed as [HTML_REMOVED].
Ideally, this should not happen. Can you please have a look into it.

@agusmakmun
Copy link
Owner

Because we using safe mode for default configuration:

MARTOR_MARKDOWN_SAFE_MODE = True

This case especially to handle xss injection, looks like <script>location.reload();</script> or etc.

But, you can also see what docs says:

  • False - Raw HTML is passed through unaltered.
  • "replace" - Replace all HTML blocks with the text assigned to html_replacement_text
  • "remove" - All raw HTML will be completely stripped from the text with no warning to the author.
  • "escape" - All raw HTML will be escaped and included in the document.

@astikanand
Copy link
Author

astikanand commented Mar 17, 2018 via email

@jdhurwitz
Copy link

@agusmakmun, When my field contains HTML as shown below, editing MARTOR_MARKDOWN_SAFE_MODE only gives me the html tags (image attached) formatted in with the text. However, I'd like these tags to be used to actually format the field itself. For example, if there is a
then there should be a line break and the user should not see any of the tags. With django-markdownx, this is supported. Am I doing something wrong here/what should I check?

&lt;p&gt;Since strings internally are converted to &lt;code&gt;uint64&lt;/code&gt; for space efficiency on the eos.io blockchain what are the restrictions that need to be followed for:&lt;/p&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;actions&lt;/li&gt;&#xA;&lt;li&gt;tables&lt;/li&gt;&#xA;&lt;li&gt;index identifiers (within &lt;code&gt;multi_index&lt;/code&gt;'s)&lt;/li&gt;&#xA;&lt;li&gt;contract names&lt;/li&gt;&#xA;&lt;li&gt;anything else I've forgotten?&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;

image

@agusmakmun
Copy link
Owner

agusmakmun commented Jul 24, 2018

@jdhurwitz yes of course, you should change to MARTOR_MARKDOWN_SAFE_MODE = False.

But, as you can see. This is dangerous method.

@jdhurwitz
Copy link

@agusmakmun Right, I have done that, but my text shown in the first box appears with the tags, whereas I want it to actually parse the tags and display it formatted.

@agusmakmun
Copy link
Owner

Simply safe the markdown content as html ouput with loading the templatetags from martor/templatetags/martortags.py.

{% load martortags %}
{{ field_name|safe_markdown }}

# example
{{ post.description|safe_markdown }}

@jdhurwitz
Copy link

I'm doing exactly that, and I still get it showing all the tags as shown in the bottom of my first comment on this thread. Here is my HTML:

image

@uditvashisht
Copy link

Hi, is there any way, in which I can add the html too ? e.g. if I want to embed a youtube video in my article or a tweet? It says <HTML_REMOVED>.

@agusmakmun
Copy link
Owner

@uditvashisht you just need to add the youtube link into editor, don't use <iframe or <embed syntax.

@uditvashisht
Copy link

uditvashisht commented Apr 4, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants