Project

General

Profile

Defect #23341 » 23341-fixed-regexp.patch

Martin Cizek, 2019-08-01 16:11

View differences:

lib/redmine/wiki_formatting/markdown/formatter.rb
24 24
        include ActionView::Helpers::TagHelper
25 25
        include Redmine::Helpers::URL
26 26

  
27
        def preprocess(full_document)
28
          replace_wiki_links(full_document, '\|', '|')
29
        end
30

  
31
        def postprocess(full_document)
32
          replace_wiki_links(full_document, '|', '|')
33
        end
34

  
27 35
        def link(link, title, content)
28 36
          return nil unless uri_with_safe_scheme?(link)
29 37

  
......
34 42
          content_tag('a', content.to_s.html_safe, :href => link, :title => title, :class => css)
35 43
        end
36 44

  
45
        def replace_wiki_links(full_document, pattern, replacement)
46
          full_document.gsub(/(\[\[(((?![\]\n]|#{pattern}).)+)(#{pattern})(((?![\]\n]|#{pattern}).)+)\]\])/) do |m|
47
            all, page, separater, title = $1, $2, $4, $5
48
            if page && separater && title
49
              "[[#{page}#{replacement}#{title}]]"
50
            else
51
              all
52
            end
53
          end
54
        end
55

  
37 56
        def block_code(code, language)
38 57
          if language.present? && Redmine::SyntaxHighlighting.language_supported?(language)
39 58
            "<pre><code class=\"#{CGI.escapeHTML language} syntaxhl\">" +
(3-3/3)