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

Markdown is URL encoding my images links in Templates #24

Open
python-force opened this issue Dec 11, 2016 · 5 comments
Open

Markdown is URL encoding my images links in Templates #24

python-force opened this issue Dec 11, 2016 · 5 comments

Comments

@python-force
Copy link

python-force commented Dec 11, 2016

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 python-force changed the title Markdown is URL encoding my images links Markdown is URL encoding my images links in Templates Dec 11, 2016
@ghost
Copy link

ghost commented Dec 25, 2016

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

@python-force
Copy link
Author

python-force commented Dec 25, 2016

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 %}

@ghost
Copy link

ghost commented Dec 26, 2016

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

@python-force
Copy link
Author

python-force commented Dec 26, 2016

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 :) )

@kichik
Copy link

kichik commented Jan 27, 2017

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.

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

2 participants