Project

General

Profile

Actions

Defect #42648

open

Wiki/CommonMark: Broken references for multiple footnote usage

Added by Luc Luc 2 days ago. Updated about 7 hours ago.

Status:
Resolved
Priority:
Normal
Category:
Text formatting
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Wiki/CommonMark: Broken references for multiple footnote usage

Description

When using the same footnote more than once with CommonMark wiki flavor, all references except the first one are broken due to the sanitization filter.

Affected version: 6.0.5.

How to reproduce

1. Use CommonMark for wiki pages
2. Create a simple wiki page containing the same footnote at least two times

This is the first usage of a footnote[^1].
Use the same footnote[^1] a second time.

[^1]: A note placed at the bottom of a page that comments on or cites a reference for a designated part of the text.


3. Observe the first back-reference is working as expected by jumping back to the first footnote usage (see #fnref-1)
4. Observe the second back-reference does not work, it doesn't jump back to the second footnote usage (see #fnref-1-2).

Proposed fix

diff --git a/lib/redmine/wiki_formatting/common_mark/sanitization_filter.rb b/lib/redmine/wiki_formatting/common_mark/sanitization_filter.rb
index cdefc372b..459610354 100644
--- a/lib/redmine/wiki_formatting/common_mark/sanitization_filter.rb
+++ b/lib/redmine/wiki_formatting/common_mark/sanitization_filter.rb
@@ -86,8 +86,8 @@ module Redmine
             node = env[:node]
             return unless node.name == "a" || node.name == "li" 
             return unless node.has_attribute?("id")
-            return if node.name == "a" && node["id"] =~ /\Afnref-\d+\z/
-            return if node.name == "li" && node["id"] =~ /\Afn-\d+\z/
+            return if node.name == "a" && node["id"] =~ /\Afnref(-\d+){1,2}\z/
+            return if node.name == "li" && node["id"] =~ /\Afn(-\d+){1,2}\z/

             node.remove_attribute("id")
           }

Files

Actions

Also available in: Atom PDF