Roundup Tracker - Issues

Issue 2551108

classification
Title: Hyperlink replaced multiple times
Type: behavior Severity: normal
Components: User Interface Versions: 2.0.0
process
Status: new Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ced, rouilj
Priority: Keywords:

Created on 2021-01-07 16:37 by ced, last changed 2021-01-11 10:34 by ced.

Messages
msg7046 Author: [hidden] (ced) Date: 2021-01-07 16:37
When using Markdown format if the message content a markdown link to an existing issue, the result is that we have a link to the issue with a text like `[issuexyz](issuexyz)`.
This is because call to `hyper_re.sub` call the method for every non-overlapping occurrence of the pattern.
I think a possible option is to use rewrite the regexp to not overlap (as suggested by https://stackoverflow.com/questions/5616822/python-regex-find-all-overlapping-matches#comment81721360_5616822).
I think also that the problem exist for other format using the same regexp.
msg7047 Author: [hidden] (rouilj) Date: 2021-01-10 02:14
Hi Cedric:

Sorry, I am lost here. What I understand is that the input text
is something like:

   issuexyz

the output between the a, /a tags is `[issuexyz](issuexyz)` or is
each of [issuexyz] and (issuezyz) a separate a tag?

Your url reference looks like it is a technique to return
multiple matches reusing subelements that have already
been matched. E.G. when matching three digits
for 123456 return:

   123 234 345 456

and not

   123 456
 
which is I don't see as applicable here.
msg7048 Author: [hidden] (ced) Date: 2021-01-10 10:04
On 2021-01-10 02:14, John Rouillard wrote:
> Sorry, I am lost here. What I understand is that the input text
> is something like:
> 
>    issuexyz
> 
> the output between the a, /a tags is `[issuexyz](issuexyz)` or is
> each of [issuexyz] and (issuezyz) a separate a tag?

No, the input is:

    [issuexyz](http://bugs.example.com/issuexyz)

And the HTML output is:

    <a href="http://bugs.example.com/issuexyz">[issuexyz](issuexyz)</a>

> Your url reference looks like it is a technique to return
> multiple matches reusing subelements that have already
> been matched. E.G. when matching three digits
> for 123456 return:
> 
>    123 234 345 456
> 
> and not
> 
>    123 456
>  
> which is I don't see as applicable here.

Maybe but the problem is that the regexp used overlaps so re.sub call
for the smallest matching but indeed we need that it calls for the
longest matching substring.
msg7049 Author: [hidden] (rouilj) Date: 2021-01-11 00:25
Ok, that's odd.

Is:

   http://bugs.example.com/issuexyz

some third party tracker? It should be the case that typing:

   issuexyz

should result in a hyperlink to issuexyz on the current tracker IIRC.
If the reference is to the local issue then I think the answer is
don't use markdown for that link.

However, what if you want to reference an issue on a third party 
tracker?

Do you know is this is due to a bad interaction between: 
cgi/templating.py:c_hyper_repl_markdown
and StringHTMLProperty::markdown? I assume that's where the call to 
self.hyper_re.sub that you originally referenced occurs.
msg7050 Author: [hidden] (ced) Date: 2021-01-11 10:34
On 2021-01-11 00:25, John Rouillard wrote:
> Is:
> 
>    http://bugs.example.com/issuexyz
> 
> some third party tracker?

No.

> It should be the case that typing:
> 
>    issuexyz
> 
> should result in a hyperlink to issuexyz on the current tracker IIRC.
> If the reference is to the local issue then I think the answer is
> don't use markdown for that link.

Yes indeed. But here it is users that are mixing both way and try to do
their best.

> However, what if you want to reference an issue on a third party 
> tracker?

It works as long as the id does not exist in the current tracker.

> Do you know is this is due to a bad interaction between: 
> cgi/templating.py:c_hyper_repl_markdown
> and StringHTMLProperty::markdown? I assume that's where the call to 
> self.hyper_re.sub that you originally referenced occurs.

What happens is that _hyper_repl_markdown is called first for the
substring: `issuexyz` which replace the string by
`[[issuexyz](issuexyz)](http://bugs.example.com/issuexyz)`.

So I guess for the `id` match group, we also need to test if it is not
surrounded by `[…]` like we do for 'url' and 'email' for `<…>`.
History
Date User Action Args
2021-01-11 10:34:03cedsetmessages: + msg7050
2021-01-11 00:25:59rouiljsetmessages: + msg7049
2021-01-10 10:04:03cedsetmessages: + msg7048
2021-01-10 02:14:23rouiljsetnosy: + rouilj
messages: + msg7047
2021-01-07 16:37:14cedcreate