django-markdown-deux icon indicating copy to clipboard operation
django-markdown-deux copied to clipboard

Markdown is URL encoding my images links in Templates

Open python-force opened this issue 9 years ago • 5 comments

Everything is working fine after installation, I am also using https://github.com/timmyomahony/django-pagedown for Admin.

When I insert the images with URL links and do not use {{ article.description }} instead of {{ article.description|markdown }} I can see the URL just fine like this:

"http://www.example.com/image.jpg" in templates.

In the Admin:

![image title][1] [1]: http://www.example.com/image.jpg

But as soon as I add template tag "markdown" - {{ article.description|markdown }}

HTML output is <img src="http%3A%2F%2Fwww.example.com%2Fimage.jpg"> and the image cannot be loaded. I have tried it on my 2 projects if I am wrong in some way but the same result.

python-force avatar Dec 11 '16 03:12 python-force

Any updates on this? I am having the same issue..

ghost avatar Dec 25 '16 22:12 ghost

This can help, I am not sure if it is proper solution but it works. MARKDOWN_DEUX_STYLES = { "default": { "extras": { "code-friendly": None, }, "safe_mode": False, }, }

Set "safe_mode" to False and in the template you can do

{% for item in items %} {{ item.description | markdown | safe }} {% endfor %}

python-force avatar Dec 25 '16 23:12 python-force

@rentgeeen Hey thanks so much for responding that helped a lot, how did you find that out btw?

ghost avatar Dec 26 '16 00:12 ghost

Look here

https://github.com/trentm/django-markdown-deux#markdown_deux_styles-setting

And notice the 2nd example: "Here is how you might add styles of your own, and preserve the default style"

I played with that code - there is safe_mode: False

But would like to know proper answer + last response here was like 2 years ago so I am not sure if it is maintained still.

(Merry Christmas :) )

python-force avatar Dec 26 '16 00:12 python-force

I would also want this fixed. Using 'safe_mode': False is not a good enough solution as it allows users to use whatever HTML they want. It's a huge security vulnerability for user generated content.

kichik avatar Jan 27 '17 01:01 kichik