From ac8d804af12a0bc566db5bc1a7b05e73bd36a333 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 08 2016 09:12:02 +0000 Subject: [PATCH 1/2] Ensure that the id is an int before querying it to the db in the markdown --- diff --git a/pagure/pfmarkdown.py b/pagure/pfmarkdown.py index 3a90113..ebf8b2a 100644 --- a/pagure/pfmarkdown.py +++ b/pagure/pfmarkdown.py @@ -63,6 +63,10 @@ class ExplicitForkIssuePattern(markdown.inlinepatterns.Pattern): user = markdown.util.AtomicString(m.group(2)) repo = markdown.util.AtomicString(m.group(3)) idx = markdown.util.AtomicString(m.group(4)) + try: + idx = int(idx) + except: + return text text = '%s/%s#%s' % (user, repo, idx) issue = _issue_exists(user, repo, idx) @@ -79,6 +83,10 @@ class ExplicitMainIssuePattern(markdown.inlinepatterns.Pattern): """ When the pattern matches, update the text. """ repo = markdown.util.AtomicString(m.group(2)) idx = markdown.util.AtomicString(m.group(3)) + try: + idx = int(idx) + except: + return text text = ' %s#%s' % (repo, idx) issue = _issue_exists(None, repo, idx) @@ -95,6 +103,10 @@ class ImplicitIssuePattern(markdown.inlinepatterns.Pattern): """ When the pattern matches, update the text. """ idx = markdown.util.AtomicString(m.group(2)) text = ' #%s' % idx + try: + idx = int(idx) + except: + return text try: root = flask.request.url_root @@ -132,6 +144,10 @@ class ImplicitPRPattern(markdown.inlinepatterns.Pattern): """ When the pattern matches, update the text. """ idx = markdown.util.AtomicString(m.group(2)) text = ' PR#%s' % idx + try: + idx = int(idx) + except: + return text try: root = flask.request.url_root From a67d6b686dd82f76e39c97d610ccb500023ea8a9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 08 2016 09:12:02 +0000 Subject: [PATCH 2/2] Fix setting the text variable before returning it (Thanks Haikel) --- diff --git a/pagure/pfmarkdown.py b/pagure/pfmarkdown.py index ebf8b2a..9068b6a 100644 --- a/pagure/pfmarkdown.py +++ b/pagure/pfmarkdown.py @@ -63,11 +63,11 @@ class ExplicitForkIssuePattern(markdown.inlinepatterns.Pattern): user = markdown.util.AtomicString(m.group(2)) repo = markdown.util.AtomicString(m.group(3)) idx = markdown.util.AtomicString(m.group(4)) + text = '%s/%s#%s' % (user, repo, idx) try: idx = int(idx) except: return text - text = '%s/%s#%s' % (user, repo, idx) issue = _issue_exists(user, repo, idx) if not issue: @@ -83,11 +83,11 @@ class ExplicitMainIssuePattern(markdown.inlinepatterns.Pattern): """ When the pattern matches, update the text. """ repo = markdown.util.AtomicString(m.group(2)) idx = markdown.util.AtomicString(m.group(3)) + text = ' %s#%s' % (repo, idx) try: idx = int(idx) except: return text - text = ' %s#%s' % (repo, idx) issue = _issue_exists(None, repo, idx) if not issue: