Project

General

Profile

Actions

Defect #31695

closed

Convert HTML links to Textile/Markdown links when creating an issue from an email

Added by Yuichi HARADA over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Email receiving
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

When creating an issue from HTML format email, the href attribute of the A tag disappears, and only the string is acquired.

[Input]

foo<a href="http://example.com/">bar</a>baz

[Expected]

foo "bar":http://example.com/ baz

[Actual]

foobarbaz


Files

fixed-31695.patch (4.05 KB) fixed-31695.patch Yuichi HARADA, 2019-07-08 10:34
tests_for_a_elements_without_href.patch (1.75 KB) tests_for_a_elements_without_href.patch Marius BĂLTEANU, 2019-11-04 21:10
fix_for_links_without_href.patch (1.97 KB) fix_for_links_without_href.patch Marius BĂLTEANU, 2019-11-04 21:11
Actions #1

Updated by Yuichi HARADA over 4 years ago

I attached a patch for Textile and Markdown.

Actions #2

Updated by Go MAEDA over 4 years ago

  • Target version set to Candidate for next major release
Actions #3

Updated by Go MAEDA over 4 years ago

  • Target version changed from Candidate for next major release to 4.1.0

Setting the target version to 4.1.0.

Actions #4

Updated by Go MAEDA over 4 years ago

  • Subject changed from Convert the A tag to Textile / Markdown when creating an issues from HTML email to Convert HTML links to Textile/Markdown links when creating an issue from an email
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you for improving Redmine.

Actions #5

Updated by Marius BĂLTEANU over 4 years ago

The current implementation fails with the following error if the link doesn't contain the href attribute.

Error:
Redmine::WikiFormatting::MarkdownHtmlParserTest#test_should_not_convert_a_tag_without_href:
NoMethodError: undefined method `value' for nil:NilClass
    lib/redmine/wiki_formatting/markdown/html_parser.rb:40:in `block in <class:HtmlParser>'
    lib/redmine/wiki_formatting/html_parser.rb:58:in `scrub'
    lib/redmine/wiki_formatting/html_parser.rb:36:in `to_text'
    test/unit/lib/redmine/wiki_formatting/markdown_html_parser_test.rb:41:in `test_should_not_convert_a_tag_without_href'

I'm attaching:
1. Tests for for markdown and textile which fail on the current trunk
2. A proposed fix, but I'm not sure if foo<a name="Header-one">bar</a>baz should be converted to foo bar baz or to foobarbaz.

Actions #6

Updated by Go MAEDA over 4 years ago

Marius BALTEANU wrote:

The current implementation fails with the following error if the link doesn't contain the href attribute.

Thank you for catching and fixing the error.

2. A proposed fix, but I'm not sure if foo<a name="Header-one">bar</a>baz should be converted to foo bar baz or to foobarbaz.

I think we can omit the surrounding spaces for that case. Text generated from `<a href="http://www.example.com/">foo</a>` style HTML should have surrounding spaces because Textile link `"foo":http://www.example.com/` does not work without surrounding spaces. However, the text "bar" you will get by converting from `<a name="Header-one">bar</a>` does not have any markup and will be always rendered properly. So, I think the surrounding spaces are unnecessary.

Actions #7

Updated by Marius BĂLTEANU over 4 years ago

Go MAEDA wrote:

Marius BALTEANU wrote:

The current implementation fails with the following error if the link doesn't contain the href attribute.

Thank you for catching and fixing the error.

2. A proposed fix, but I'm not sure if foo<a name="Header-one">bar</a>baz should be converted to foo bar baz or to foobarbaz.

I think we can omit the surrounding spaces for that case. Text generated from `<a href="http://www.example.com/">foo</a>` style HTML should have surrounding spaces because Textile link `"foo":http://www.example.com/` does not work without surrounding spaces. However, the text "bar" you will get by converting from `<a name="Header-one">bar</a>` does not have any markup and will be always rendered properly. So, I think the surrounding spaces are unnecessary.

Great! Please feel free to update the patches.

Actions #8

Updated by Go MAEDA over 4 years ago

  • Status changed from Reopened to Closed

Marius BALTEANU wrote:

The current implementation fails with the following error if the link doesn't contain the href attribute.

Committed the patches. Thank you.

Actions

Also available in: Atom PDF