Skip to content

Commit 3ec0cc3

Browse files
author
Agus Makmun
committed
fix: unitest, remove incompatible version, update locale
1 parent cc5fd73 commit 3ec0cc3

File tree

6 files changed

+28
-56
lines changed

6 files changed

+28
-56
lines changed

.travis.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ matrix:
2323
env: DJANGO="==3.1.*"
2424
- python: 3.6
2525
env: DJANGO="==3.2.*"
26-
- python: 3.6
27-
env: DJANGO="==4.0"
2826

2927
- python: 3.7
3028
env: DJANGO="==2.0.*"
@@ -38,8 +36,6 @@ matrix:
3836
env: DJANGO="==3.1.*"
3937
- python: 3.7
4038
env: DJANGO="==3.2.*"
41-
- python: 3.7
42-
env: DJANGO="==4.0"
4339

4440
- python: 3.8
4541
env: DJANGO="==2.0.*"
@@ -73,7 +69,7 @@ matrix:
7369

7470
- os: osx
7571
language: generic
76-
env: DJANGO="==4.0"
72+
env: DJANGO="==3.2.*"
7773

7874
# Perform the manual steps on OSX to install Python3 and activate venv:
7975
# Since Python versions have been tested on Linux and it is only a matter of

martor/locale/en/LC_MESSAGES/django.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2021-03-10 08:32+0700\n"
11+
"POT-Creation-Date: 2021-12-21 20:12+0700\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -179,11 +179,11 @@ msgstr ""
179179
msgid "Invalid request!"
180180
msgstr ""
181181

182-
#: views.py:75
182+
#: views.py:74
183183
#, python-format
184184
msgid "No users registered as `%(username)s` or user is unactived."
185185
msgstr ""
186186

187-
#: views.py:80
187+
#: views.py:79
188188
msgid "Validation Failed for field `username`"
189189
msgstr ""

martor/locale/id/LC_MESSAGES/django.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2021-03-10 08:32+0700\n"
11+
"POT-Creation-Date: 2021-12-21 20:13+0700\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -181,13 +181,13 @@ msgstr "Bantuan Penggunaan Markdown"
181181
msgid "Invalid request!"
182182
msgstr "Permintaan tidak valid"
183183

184-
#: views.py:75
184+
#: views.py:74
185185
#, python-format
186186
msgid "No users registered as `%(username)s` or user is unactived."
187187
msgstr ""
188188
"Tidak ada pengguna terdaftar sebagai `%(username)s` atau pengguna telah "
189189
"nonaktif."
190190

191-
#: views.py:80
191+
#: views.py:79
192192
msgid "Validation Failed for field `username`"
193193
msgstr "Validasi Gagal untuk field `username`"

martor/locale/tr/LC_MESSAGES/django.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2021-03-10 08:33+0700\n"
11+
"POT-Creation-Date: 2021-12-21 20:13+0700\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: Ozcan Yarimdunya <[email protected]>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -182,11 +182,11 @@ msgstr "Markdown Kılavuzu (Yardım)"
182182
msgid "Invalid request!"
183183
msgstr "Geçersiz istek!"
184184

185-
#: views.py:75
185+
#: views.py:74
186186
#, python-format
187187
msgid "No users registered as `%(username)s` or user is unactived."
188188
msgstr "`%(username)s` kullanıcı kayıtlı değil veya aktif değil"
189189

190-
#: views.py:80
190+
#: views.py:79
191191
msgid "Validation Failed for field `username`"
192192
msgstr "`kullanıcı adı` alanı için doğrulama başarısız"

martor/tests/tests.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.test import TestCase, override_settings
22
from django.contrib.auth.models import User
3-
from martor.utils import markdownify, VersionNotCompatible
3+
from martor.utils import markdownify
44

55

66
class SimpleTest(TestCase):
@@ -77,18 +77,6 @@ def test_markdownify(self):
7777
# '...fixme'
7878
# )
7979

80-
def test_markdownify_error(
81-
self,
82-
):
83-
# This tests that real errors don't raise VersionNotCompatible
84-
# errors, which could be misleading.
85-
try:
86-
markdownify(None)
87-
except Exception as e:
88-
self.assertNotIsInstance(e, VersionNotCompatible)
89-
else:
90-
self.fail("no assertion raised")
91-
9280
def test_markdownify_xss_handled(self):
9381
xss_payload = "[aaaa](javascript:alert(1))"
9482
response = markdownify(xss_payload)

martor/utils.py

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
)
1818

1919

20-
class VersionNotCompatible(Exception):
21-
pass
22-
23-
2420
def markdownify(markdown_text):
2521
"""
2622
Render the markdown content to HTML.
@@ -32,33 +28,25 @@ def markdownify(markdown_text):
3228
'<p><img alt="awesome" src="http://i.imgur.com/hvguiSn.jpg" /></p>'
3329
>>>
3430
"""
35-
try:
36-
# Strip HTML tags
37-
markdown_text = strip_tags(markdown_text)
31+
# Strip HTML tags
32+
markdown_text = strip_tags(markdown_text)
3833

39-
# Sanitize Markdown links
40-
# https://github.com/netbox-community/netbox/commit/5af2b3c2f577a01d177cb24cda1019551a2a4b64
41-
schemes = "|".join(ALLOWED_URL_SCHEMES)
42-
pattern = fr"\[(.+)\]\((?!({schemes})).*:(.+)\)"
43-
markdown_text = re.sub(
44-
pattern,
45-
"[\\1](\\3)",
46-
markdown_text,
47-
flags=re.IGNORECASE,
48-
)
34+
# Sanitize Markdown links
35+
# https://github.com/netbox-community/netbox/commit/5af2b3c2f577a01d177cb24cda1019551a2a4b64
36+
schemes = "|".join(ALLOWED_URL_SCHEMES)
37+
pattern = fr"\[(.+)\]\((?!({schemes})).*:(.+)\)"
38+
markdown_text = re.sub(
39+
pattern,
40+
"[\\1](\\3)",
41+
markdown_text,
42+
flags=re.IGNORECASE,
43+
)
4944

50-
return markdown.markdown(
51-
markdown_text,
52-
extensions=MARTOR_MARKDOWN_EXTENSIONS,
53-
extension_configs=MARTOR_MARKDOWN_EXTENSION_CONFIGS,
54-
)
55-
except TypeError as e:
56-
if "extendMarkdown" not in str(e):
57-
raise
58-
raise VersionNotCompatible(
59-
"The markdown isn't compatible, please reinstall "
60-
"your python markdown into Markdown>=3.0"
61-
)
45+
return markdown.markdown(
46+
markdown_text,
47+
extensions=MARTOR_MARKDOWN_EXTENSIONS,
48+
extension_configs=MARTOR_MARKDOWN_EXTENSION_CONFIGS,
49+
)
6250

6351

6452
class LazyEncoder(DjangoJSONEncoder):

0 commit comments

Comments
 (0)