From e364044e4973d507910e28fcfc42c60d4df5602d Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon
Date: Apr 04 2017 08:14:35 +0000
Subject: [PATCH 1/2] Fix our markdown processor for strikethrough
Fixes https://pagure.io/pagure/issue/2198
---
diff --git a/pagure/pfmarkdown.py b/pagure/pfmarkdown.py
index 57062b4..4308587 100644
--- a/pagure/pfmarkdown.py
+++ b/pagure/pfmarkdown.py
@@ -54,7 +54,7 @@ COMMIT_LINK_RE = r'(?\w#])([a-f0-9]{7,40})'
-STRIKE_THROUGH_RE = r'~~(\w+)~~'
+STRIKE_THROUGH_RE = r'~~(.*)~~'
class MentionPattern(markdown.inlinepatterns.Pattern):
diff --git a/tests/test_pagure_lib.py b/tests/test_pagure_lib.py
index 0abb498..63ad1f6 100644
--- a/tests/test_pagure_lib.py
+++ b/tests/test_pagure_lib.py
@@ -3424,6 +3424,13 @@ class PagureLibtests(tests.Modeltests):
'ircs://pagure.io',
'http://pagure.io',
'https://pagure.io',
+ '~~foo~~',
+ '~~foo bar~~',
+ '~~[BZ#1435310](https://bugzilla.redhat.com/1435310)~~',
+ "~~[BZ#1435310](https://bugzilla.redhat.com/1435310) avc denial "
+ "during F26AH boot 'error_name=org.freedesktop.systemd1."
+ "NoSuchDynamicUser'~~",
+ '``~~foo bar~~``',
]
expected = [
# 'foo bar test#1 see?',
@@ -3476,6 +3483,21 @@ class PagureLibtests(tests.Modeltests):
'http://pagure.io
',
# 'https://pagure.io'
'https://pagure.io
',
+ # '~~foo~~'
+ 'foo
',
+ # '~~foo bar~~'
+ 'foo bar
',
+ # '~~[BZ#1435310](https://bugzilla.redhat.com/1435310)~~'
+ ''
+ 'BZ#1435310
',
+ # '~~[BZ#1435310](https://bugzilla.redhat.com/1435310) avc
+ # denial during F26AH boot 'error_name=org.freedesktop.systemd1
+ # .NoSuchDynamicUser~~'
+ ""
+ "BZ#1435310 avc denial during F26AH boot 'error_name="
+ "org.freedesktop.systemd1.NoSuchDynamicUser'
",
+ # '``~~foo bar~~``'
+ '~~foo bar~~
',
]
with pagure.APP.app_context():
From 33786e9153dee7c85d2dd61816c6a0099e54667c Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon
Date: Apr 04 2017 08:14:35 +0000
Subject: [PATCH 2/2] Make the strikethrough regex non-greedy and add a test for this
---
diff --git a/pagure/pfmarkdown.py b/pagure/pfmarkdown.py
index 4308587..4be6cb8 100644
--- a/pagure/pfmarkdown.py
+++ b/pagure/pfmarkdown.py
@@ -54,7 +54,7 @@ COMMIT_LINK_RE = r'(?\w#])([a-f0-9]{7,40})'
-STRIKE_THROUGH_RE = r'~~(.*)~~'
+STRIKE_THROUGH_RE = r'~~(.*?)~~'
class MentionPattern(markdown.inlinepatterns.Pattern):
diff --git a/tests/test_pagure_lib.py b/tests/test_pagure_lib.py
index 63ad1f6..4fa467f 100644
--- a/tests/test_pagure_lib.py
+++ b/tests/test_pagure_lib.py
@@ -3431,6 +3431,7 @@ class PagureLibtests(tests.Modeltests):
"during F26AH boot 'error_name=org.freedesktop.systemd1."
"NoSuchDynamicUser'~~",
'``~~foo bar~~``',
+ '~~foo bar~~ and ~~another ~~',
]
expected = [
# 'foo bar test#1 see?',
@@ -3498,6 +3499,8 @@ class PagureLibtests(tests.Modeltests):
"org.freedesktop.systemd1.NoSuchDynamicUser'
",
# '``~~foo bar~~``'
'~~foo bar~~
',
+ # '~~foo bar~~ and ~~another ~~',
+ 'foo bar and another
',
]
with pagure.APP.app_context():