Project

General

Profile

Defect #30259 » 0002-Interpret-trailing-hyphens-as-URL.patch

Yuichi HARADA, 2019-01-08 09:07

View differences:

lib/redmine/wiki_formatting.rb
125 125
                        ([^<]\S*?)               # url
126 126
                        (\/)?                    # slash
127 127
                      )
128
                      ((?:&gt;)?|[^[:alnum:]_\=\/;\(\)]*?)               # post
128
                      ((?:&gt;)?|[^[:alnum:]_\=\/;\(\)\-]*?)             # post
129 129
                      (?=<|\s|$)
130 130
                     }x unless const_defined?(:AUTO_LINK_RE)
131 131

  
lib/redmine/wiki_formatting/textile/redcloth3.rb
271 271

  
272 272
        @urlrefs = {}
273 273
        @shelf = []
274
        textile_rules = [:block_textile_table, :block_textile_lists,
275
                         :block_textile_prefix, :inline_textile_image, :inline_textile_link,
276
                         :inline_textile_code, :inline_textile_span, :glyphs_textile]
274
        textile_rules = [:block_textile_table, :block_textile_lists, :block_textile_prefix,
275
                         :inline_textile_image, :inline_textile_code, :inline_textile_span, :inline_textile_link,
276
                         :glyphs_textile]
277 277
        markdown_rules = [:refs_markdown, :block_markdown_setext, :block_markdown_atx, :block_markdown_rule,
278 278
                          :block_markdown_bq, :block_markdown_lists,
279 279
                          :inline_markdown_reflink, :inline_markdown_link]
......
828 828
            [[:alnum:]_\/]\S+?
829 829
            )
830 830
            (\/)?                      # $slash
831
            ([^[:alnum:]_\=\/;\(\)]*?)         # $post
831
            ([^[:alnum:]_\=\/;\(\)\-]*?)       # $post
832 832
            )
833 833
            (?=<|\s|$)
834 834
        /x
test/helpers/application_helper_test.rb
282 282
    to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
283 283
  end
284 284

  
285
  def test_textile_links_with_hyphens
286
    to_test = {
287
      '(see "inline link":http://www.foo.bar/Test-)' => '(see <a href="http://www.foo.bar/Test-" class="external">inline link</a>)',
288
      'http://foo.bar/page?p=1&t=z&s=-' => '<a class="external" href="http://foo.bar/page?p=1&#38;t=z&#38;s=-">http://foo.bar/page?p=1&#38;t=z&#38;s=-</a>',
289
      'This is an intern "link":/foo/bar-' => 'This is an intern <a href="/foo/bar-">link</a>',
290
    }
291
    to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
292
  end
293

  
285 294
  def test_redmine_links
286 295
    user_with_email_login = User.generate!(:login => 'abcd@example.com')
287 296
    user_with_email_login_2 = User.generate!(:login => 'foo.bar@example.com')
test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
621 621
    assert_equal expected.gsub(%r{[\r\n\t]}, ''), to_html(text).gsub(%r{[\r\n\t]}, '')
622 622
  end
623 623

  
624
  def test_should_link_url_with_hyphens
625
    assert_html_output({
626
      'http://www.redmine.org/example-' => '<a class="external" href="http://www.redmine.org/example-">http://www.redmine.org/example-</a>'
627
    })
628
  end
629

  
624 630
  private
625 631

  
626 632
  def assert_html_output(to_test, expect_paragraph = true)
(3-3/4)