From 276bc3bc2bae2c793da534645a1bd7349426076a Mon Sep 17 00:00:00 2001 From: "Michael J. Schultz" Date: Thu, 5 Nov 2015 10:47:56 -0600 Subject: [PATCH 1/5] Remove safe_mode since it is not safe. --- rest_framework/compat.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 8b782a1c26..55b6fde232 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -160,8 +160,7 @@ def apply_markdown(text): """ extensions = ['headerid(level=2)'] - safe_mode = False - md = markdown.Markdown(extensions=extensions, safe_mode=safe_mode) + md = markdown.Markdown(extensions=extensions) return md.convert(text) except ImportError: apply_markdown = None From d9d34e4886c283653bc7d9e50a414ab07ee8bb93 Mon Sep 17 00:00:00 2001 From: "Michael J. Schultz" Date: Thu, 5 Nov 2015 10:48:19 -0600 Subject: [PATCH 2/5] Use full python dot path to extension --- rest_framework/compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 55b6fde232..a6596d19df 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -159,7 +159,7 @@ def apply_markdown(text): of '#' style headers to

. """ - extensions = ['headerid(level=2)'] + extensions = ['markdown.extensions.headerid(level=2)'] md = markdown.Markdown(extensions=extensions) return md.convert(text) except ImportError: From b2e74fb523ff2488106a5004e1e70d2fd0592929 Mon Sep 17 00:00:00 2001 From: "Michael J. Schultz" Date: Thu, 5 Nov 2015 10:52:31 -0600 Subject: [PATCH 3/5] Use markdown 2.6 extension_configs to configure extension --- rest_framework/compat.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index a6596d19df..70cb0485c4 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -159,8 +159,15 @@ def apply_markdown(text): of '#' style headers to

. """ - extensions = ['markdown.extensions.headerid(level=2)'] - md = markdown.Markdown(extensions=extensions) + extensions = ['markdown.extensions.headerid'] + extension_configs = { + 'markdown.extensions.headerid': { + 'level': '2' + } + } + md = markdown.Markdown( + extensions=extensions, extension_configs=extension_configs + ) return md.convert(text) except ImportError: apply_markdown = None From abc6fa05e685ea5fe4cf3b3ff4fe875463f07b1c Mon Sep 17 00:00:00 2001 From: "Michael J. Schultz" Date: Mon, 9 Nov 2015 11:47:00 -0600 Subject: [PATCH 4/5] Markdown 2.1 compatible --- rest_framework/compat.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 70cb0485c4..bb7cae0553 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -152,16 +152,19 @@ def __init__(self, *args, **kwargs): try: import markdown + if markdown.version <= '2.2': + HEADERID_EXT_PATH = 'headerid' + else: + HEADERID_EXT_PATH = 'markdown.extensions.headerid' def apply_markdown(text): """ Simple wrapper around :func:`markdown.markdown` to set the base level of '#' style headers to

. """ - - extensions = ['markdown.extensions.headerid'] + extensions = [HEADERID_EXT_PATH] extension_configs = { - 'markdown.extensions.headerid': { + HEADERID_EXT_PATH: { 'level': '2' } } From f308900a5fa3f37f5853180c5bde92b681749c04 Mon Sep 17 00:00:00 2001 From: "Michael J. Schultz" Date: Mon, 9 Nov 2015 11:48:17 -0600 Subject: [PATCH 5/5] Bump the markdown optional requirement as well --- requirements/requirements-optionals.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/requirements-optionals.txt b/requirements/requirements-optionals.txt index 3ada43ebd5..0221b211e1 100644 --- a/requirements/requirements-optionals.txt +++ b/requirements/requirements-optionals.txt @@ -1,4 +1,4 @@ # Optional packages which may be used with REST framework. -markdown==2.5.2 +markdown==2.6.4 django-guardian==1.3.0 django-filter==0.10.0