View Issue Details

IDProjectCategoryView StatusLast Update
0034389mantisbtmarkdownpublic2024-04-03 06:45
Reporterdregad Assigned Tocommunity  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Target Version2.27.0 
Summary0034389: Broken rendering of links in <a href=... links when markdown is enabled
Description

Following merge of PR 1976 to fix 0034040, <a href... links are not rendered as expected when Markdown is enabled and process_url = ON (see attached image.png).

<a href="https://example.com">Link</a>

<a href="https://example.com">Link</a>

Following analysis by @hotzeplotz this is likely caused by a bug in Parsedown.

Additional Information

See original discussion in PR 1976
https://github.com/mantisbt/mantisbt/pull/1976#issuecomment-2030712795

TagsNo tags attached.
Attached Files
image.png (10,730 bytes)   
image.png (10,730 bytes)   

Activities

hotzeplotz

hotzeplotz

2024-04-02 17:42

reporter   ~0068779

Last edited: 2024-04-03 03:54

Caused by the regex used by the inlineUrl method. https://github.com/erusev/parsedown/blob/1ff038273949df7d6a455352659a878f3c89b29c/Parsedown.php#L1540

if (strpos($Excerpt['context'], 'http') !== false
    and preg_match('/\bhttps?+:[\/]{2}[^\s<]+\b\/*+/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE)                                                          
)

The regex fail is the boundery " is not followd by a whitespace. href="…"> fail, while href="" > works.

Fail: https://regex101.com/r/kabj3Q/1

Possible fix

https://regex101.com/r/5h5eLe/1

/\bhttps?+:[\/]{2}[^\s<"]+\b\/*+/ui'
                       ^ Adding a " here

It is possible that the other regular expressions for the links also have such a problem … just uncovered.

hotzeplotz

hotzeplotz

2024-04-02 17:45

reporter   ~0068780

Last edited: 2024-04-03 06:45

side note, the textarea needs a nice monospace font, to enable the reporter to place some markings to the right position :-)

hotzeplotz

hotzeplotz

2024-04-02 17:51

reporter   ~0068781

parsedown-html-anchorr-fix.png (30,574 bytes)   
parsedown-html-anchorr-fix.png (30,574 bytes)   
parsedown-html-anchor-fail.png (34,288 bytes)   
parsedown-html-anchor-fail.png (34,288 bytes)