Skip to content

Commit 5d57688

Browse files
author
Agus Makmun
committed
fix: embedding html code #174
1 parent 138afe7 commit 5d57688

File tree

10 files changed

+24
-23
lines changed

10 files changed

+24
-23
lines changed

martor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
__VERSION__ = "1.6.10"
3+
__VERSION__ = "1.6.11"
44
__AUTHOR__ = "Agus Makmun (Summon Agus)"
55
__AUTHOR_EMAIL__ = "summon.agus@gmail.com"

martor/static/martor/css/martor-admin.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

martor/static/martor/css/martor.bootstrap.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

martor/static/martor/css/martor.semantic.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

martor/static/martor/js/martor.bootstrap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* Name : Martor v1.6.10
2+
* Name : Martor v1.6.11
33
* Created by : Agus Makmun (Summon Agus)
4-
* Release date : 26-Jan-2022
4+
* Release date : 21-Feb-2022
55
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
66
* Repository : https://github.com/agusmakmun/django-markdown-editor
77
**/

martor/static/martor/js/martor.bootstrap.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

martor/static/martor/js/martor.semantic.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* Name : Martor v1.6.10
2+
* Name : Martor v1.6.11
33
* Created by : Agus Makmun (Summon Agus)
4-
* Release date : 26-Jan-2022
4+
* Release date : 21-Feb-2022
55
* License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
66
* Repository : https://github.com/agusmakmun/django-markdown-editor
77
**/

martor/static/martor/js/martor.semantic.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

martor/tests/tests.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_markdownify(self):
6363
self.assertEqual(response.status_code, 200)
6464
self.assertEqual(
6565
response.content.decode("utf-8"),
66-
'<p><img alt="image" src="https://imgur.com/test.png" /></p>',
66+
'<p><img alt="image" src="https://imgur.com/test.png"></p>',
6767
) # noqa: E501
6868

6969
# # Mention
@@ -78,6 +78,10 @@ def test_markdownify(self):
7878
# )
7979

8080
def test_markdownify_xss_handled(self):
81-
xss_payload = "[aaaa](javascript:alert(1))"
82-
response = markdownify(xss_payload)
83-
self.assertEqual(response, '<p><a href="alert(1)">aaaa</a></p>')
81+
xss_payload_1 = "[aaaa](javascript:alert(1))"
82+
response_1 = markdownify(xss_payload_1)
83+
self.assertEqual(response_1, '<p><a href=":">aaaa</a></p>')
84+
85+
# xss_payload_2 = "![\" onerror=alert(1) ](x)"
86+
# response_2 = markdownify(xss_payload_2)
87+
# self.assertEqual(response_2, '')

martor/utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import re
22

3-
from django.utils.html import strip_tags
43
from django.utils.functional import Promise
54
from django.core.serializers.json import DjangoJSONEncoder
65

@@ -28,9 +27,6 @@ def markdownify(markdown_text):
2827
'<p><img alt="awesome" src="http://i.imgur.com/hvguiSn.jpg" /></p>'
2928
>>>
3029
"""
31-
# Strip HTML tags
32-
markdown_text = strip_tags(markdown_text)
33-
3430
# Sanitize Markdown links
3531
# https://github.com/netbox-community/netbox/commit/5af2b3c2f577a01d177cb24cda1019551a2a4b64
3632
schemes = "|".join(ALLOWED_URL_SCHEMES)
@@ -46,6 +42,7 @@ def markdownify(markdown_text):
4642
markdown_text,
4743
extensions=MARTOR_MARKDOWN_EXTENSIONS,
4844
extension_configs=MARTOR_MARKDOWN_EXTENSION_CONFIGS,
45+
output_format="html5",
4946
)
5047

5148

0 commit comments

Comments
 (0)