Skip to content

Bug Fix: Automatic issue linking escaping inline codeblocks #1728

@oskarnurm

Description

@oskarnurm

Description

While working on #1724, we discovered that the githubinfo passive listener incorrectly triggers on GitHub issue references inside inline code blocks, provided the code block does not start at the beginning of a line.

Steps to Reproduce

Send the message "I am looking at python-discord/bot#123 right now"

Expected Behaviour

Should not trigger the bot's passive listener.

Actual Behaviour

Incorrectly triggers the bot to fetch the issue.
Image

Known Impacted Platforms

  • Web
  • Desktop
  • Android App
  • iOS App

Possible Solutions

I think the issue stems from:

CODE_BLOCK_RE = re.compile(
r"^`([^`\n]+)`" # Inline codeblock
r"|```(.+?)```", # Multiline codeblock
re.DOTALL | re.MULTILINE
)

Where the CODE_BLOCK_RE regex anchors the match exclusively to the start of the string/line.
A possible fix would be to remove ^ from line 37:

CODE_BLOCK_RE = re.compile(
    r"`([^`\n]+)`"    # Removed the ^ 
    r"|```(.+?)```",  
    re.DOTALL | re.MULTILINE
)

Would you like to implement a fix?

  • I'd like to implement the bug fix
  • Anyone can implement the bug fix

We can fix this when we implement #1724

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions