From 0d79b6266d583d0d809a6fff3c10097dd28f468e Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Sun, 21 Nov 2021 23:25:54 -0500 Subject: [PATCH 1/3] Backport patch for #985 --- helpdesk/models.py | 13 +++++++++++++ helpdesk/settings.py | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/helpdesk/models.py b/helpdesk/models.py index 7f18cf20..f8ffb8b1 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -56,6 +56,19 @@ def get_markdown(text): if not text: return "" + pattern = fr'([\[\s\S\]]*?)\(([\s\S]*?):([\s\S]*?)\)' + # Regex check + if re.match(pattern, text): + # get get value of group regex + scheme = re.search(pattern, text, re.IGNORECASE).group(2) + # scheme check + if scheme in helpdesk_settings.ALLOWED_URL_SCHEMES: + replacement = '\\1(\\2:\\3)' + else: + replacement = '\\1(\\3)' + + text = re.sub(pattern, replacement, text, flags=re.IGNORECASE) + return mark_safe( markdown( text, diff --git a/helpdesk/settings.py b/helpdesk/settings.py index 6437502e..c68cc4b9 100644 --- a/helpdesk/settings.py +++ b/helpdesk/settings.py @@ -76,7 +76,10 @@ HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE = getattr(settings, 'HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE', False) - +# URL schemes that are allowed within links +ALLOWED_URL_SCHEMES = getattr(settings, 'ALLOWED_URL_SCHEMES', ( + 'file', 'ftp', 'ftps', 'http', 'https', 'irc', 'mailto', 'sftp', 'ssh', 'tel', 'telnet', 'tftp', 'vnc', 'xmpp', +)) ############################ # options for public pages # ############################ From e7de309159dad498bbb1d8dcf2c24986860772b6 Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Sun, 21 Nov 2021 23:36:17 -0500 Subject: [PATCH 2/3] Update CONTRIBUTING for the new branch naming scheme --- CONTRIBUTING.rst | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 8edda10b..564b2d26 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -19,7 +19,7 @@ Testing ------- If you don't mind testing pre-releases (don't use in production!), we appreciate -continuous feedback on the `master` branch, which is our work toward the next +continuous feedback on the `unstable` branch, which is our work toward the next major release. Please file bug reports, and tag the report with the "pre-release" tag. @@ -35,21 +35,27 @@ pull request back into the appropriate branch of the Short story: -* pull requests for `master` are for the next major release -* pull requests for a current release should go to appropriate release branch - (for example, bugfixes for 0.3 should go to the `0.3` branch.) +* pull requests for `unstable` are for the next major release +* pull requests for `stable` are for the current release Longer story: In general, our git branching scheme looks like the following. -* `master` always points to development for the next major release, +* `unstable` always points to development for the next major release, major new features should go here -* current and past major releases are found in their own branches: +* `stable` always points to the latest stable release, + bugfixes and security patches should go here +* current and past major releases can also be found in their own branches: * `0.3` is the branch for the 0.3 release and any bugfix releases * `0.2.x` is the branch for the 0.2 release and any bugfix releases * `0.1` is the branch for the legacy code; it is no longer supported + +If you want to submit a specific patch for an older release, +you can put your pull request against that branch specifically. +However, we don't currently support any older release beyond +the latest release (currently 0.3). We reserve the right to decline a pull request if it is not for the appropriate branch. From 94902ec44fc93d1e9fd2858cc2327902d028137a Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Sun, 21 Nov 2021 23:37:25 -0500 Subject: [PATCH 3/3] Bump version to 0.3.2 for bugfix --- demo/setup.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/setup.py b/demo/setup.py index 55cc2382..0b676a81 100644 --- a/demo/setup.py +++ b/demo/setup.py @@ -13,7 +13,7 @@ project_root = os.path.dirname(here) NAME = 'django-helpdesk-demodesk' DESCRIPTION = 'A demo Django project using django-helpdesk' README = open(os.path.join(here, 'README.rst')).read() -VERSION = '0.3.1' +VERSION = '0.3.2' #VERSION = open(os.path.join(project_root, 'VERSION')).read().strip() AUTHOR = 'django-helpdesk team' URL = 'https://github.com/django-helpdesk/django-helpdesk' diff --git a/setup.py b/setup.py index 5aceddb2..916bb729 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from distutils.util import convert_path from fnmatch import fnmatchcase from setuptools import setup, find_packages -version = '0.3.1' +version = '0.3.2' # Provided as an attribute, so you can append to these instead # of replicating them: