From e364044e4973d507910e28fcfc42c60d4df5602d Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
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)'\
 IMPLICIT_ISSUE_RE = r'[^|\w](?<!\w)#([0-9]+)'
 IMPLICIT_PR_RE = r'[^|\w](?<!\w)PR#([0-9]+)'
 IMPLICIT_COMMIT_RE = r'[^|\w](?<![>\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):
             '<p><a href="http://pagure.io">http://pagure.io</a></p>',
             # 'https://pagure.io'
             '<p><a href="https://pagure.io">https://pagure.io</a></p>',
+            # '~~foo~~'
+            '<p><del>foo</del></p>',
+            # '~~foo bar~~'
+            '<p><del>foo bar</del></p>',
+            # '~~[BZ#1435310](https://bugzilla.redhat.com/1435310)~~'
+            '<p><del><a href="https://bugzilla.redhat.com/1435310">'
+            'BZ#1435310</a></del></p>',
+            # '~~[BZ#1435310](https://bugzilla.redhat.com/1435310) avc
+            # denial during F26AH boot 'error_name=org.freedesktop.systemd1
+            # .NoSuchDynamicUser~~'
+            "<p><del><a href=\"https://bugzilla.redhat.com/1435310\">"
+            "BZ#1435310</a> avc denial during F26AH boot 'error_name="
+            "org.freedesktop.systemd1.NoSuchDynamicUser'</del></p>",
+            # '``~~foo bar~~``'
+            '<p><code>~~foo bar~~</code></p>',
         ]
 
         with pagure.APP.app_context():

From 33786e9153dee7c85d2dd61816c6a0099e54667c Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
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)'\
 IMPLICIT_ISSUE_RE = r'[^|\w](?<!\w)#([0-9]+)'
 IMPLICIT_PR_RE = r'[^|\w](?<!\w)PR#([0-9]+)'
 IMPLICIT_COMMIT_RE = r'[^|\w](?<![>\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'</del></p>",
             # '``~~foo bar~~``'
             '<p><code>~~foo bar~~</code></p>',
+            # '~~foo bar~~ and ~~another ~~',
+            '<p><del>foo bar</del> and <del>another </del></p>',
         ]
 
         with pagure.APP.app_context():

