Opened 3 years ago

Closed 3 years ago

# Exclude InterTrac ticket references

Reported by: Owned by: Marcel Gestewitz lucid normal PageTicketsMacro normal clemens

### Description

The useful PageTickets macro should avoid to list also ticket numbers which are not intended to be a reference to a ticket.

On the one hand this can be InterTrac links to tickets of other TRAC repositories. Furthermore this may also be escaped references like #13523.

For me it works to adapt the regular expression to the following statement:

tickets_re = re.compile('(?:(?:^|(?:[\s,;.-]))(?:#|(?:ticket:|issue:|bug:)))(\d+)')


With this statement ticket references needs to be

• at the very beginning of the text
• preceded by a white space, dot, comma, semicolon, hyphen

In other cases keywords for ticket references are ignored.

# Relation

This change may also be of interest for the MentionedTickets plugin.

### comment:1 Changed 3 years ago by clemens

Hello

We use a lot of InterTrac links and in my opinion it makes sense to exclude them from the PageTickets macro, because the underlying TicketQuery cannot resolve those external InterTrac links anyway.

Ditto for the MentionedTicketsPlugin.

Clemens

### comment:2 follow-up:  3 Changed 3 years ago by anonymous

Are all the (?: ) needed?

tickets_re = re.compile("""
(?:
^            # At the beginning of the text
|            # OR
[\s,;.-]     # After whitespace or punctuation
)
(?:
\#           # #
|            # OR
ticket:      # ticket:
|            # OR
issue:       # issue:
|            # OR
bug:         # bug:
)
(\d+)            # Group 1: The ticket number
""", re.VERBOSE)


### comment:3 in reply to:  2 Changed 3 years ago by Marcel Gestewitz

Are all the (?: ) needed?

tickets_re = re.compile("""
(?:
^            # At the beginning of the text
|            # OR
[\s,;.-]     # After whitespace or punctuation
)
(?:
\#           # #
|            # OR
ticket:      # ticket:
|            # OR
issue:       # issue:
|            # OR
bug:         # bug:
)
(\d+)            # Group 1: The ticket number
""", re.VERBOSE)


Yes this is correct and an useful reduction of the regular expression.

I added the condition for beginning of text later, thus my statement was more complex than necessary.

I did not changed the latter part. In my opinion it is also not required to split \# and the other ticket keywords. See ticket #12499. I did not know why this is the case.

Your regular expression works perfect for me.

### comment:4 Changed 3 years ago by lucid

Resolution: → wontfix new → closed

Thanks for the suggestions. Unfortunately there's a problem: This excludes links of the form comment:2:ticket:13524. Subjectively I rate this breakage higher than the exclusion of intertrac links, so for now I close this as WONTFIX. Please reopen if there's a reasobaly simple solution to this obstacle.

### comment:5 Changed 3 years ago by lucid

In 17329:

PageTicketsMacro: Include issue: references (see #13524)

### Modify Ticket

Change Properties