https://bugs.kde.org/show_bug.cgi?id=524591

            Bug ID: 524591
           Summary: Open Link plugin includes trailing ")" from enclosing
                    parentheses when opening markdown links
    Classification: Applications
           Product: kate
      Version First 26.04.3
       Reported In:
          Platform: NixOS
                OS: Linux
            Status: REPORTED
          Severity: minor
          Priority: NOR
         Component: application
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

# Open Link plugin includes trailing ")" from enclosing parentheses when
opening Markdown links

**Product:** Kate
**Component:** plugin: Open Link
**Severity:** minor

## Description

**SUMMARY**

The Open Link plugin incorrectly includes a trailing closing parenthesis in
URLs that are wrapped in parentheses, e.g. Markdown links embedded in
parenthesized text. When Ctrl+clicking such a link, the URL opened in the
browser contains a stray ")" at the end, leading to a 404 page.

**STEPS TO REPRODUCE**

1. Enable the "Open Link" plugin (Settings → Configure Kate → Plugins → Open
Link).
2. Open a document and paste the following text:

   `(for [#3695](https://github.com/pbek/QOwnNotes/issues/3695))`

3. Hover the URL with Ctrl pressed.

**OBSERVED RESULT**

The underline highlight covers `https://github.com/pbek/QOwnNotes/issues/3695)`
including the final closing parenthesis, and Ctrl+click opens
`https://github.com/pbek/QOwnNotes/issues/3695)` in the browser, which results
in a 404 error.

The URL regex allows parentheses in the path, so the match greedily consumes
the enclosing ")" characters. The trailing-character fixup only strips a single
special character, which is insufficient here since there are two closing
parens after the URL.

**EXPECTED RESULT**

The detected URL is `https://github.com/pbek/QOwnNotes/issues/3695` (without
the trailing ")").

Note that URLs containing *balanced* parentheses, such as
`https://en.wikipedia.org/wiki/Link_(film)`, must keep their trailing ")" — the
fix should only strip unbalanced closing parens.

**SOFTWARE/OS VERSIONS**

- Kate: 26.11.70 (current master)
- Operating System: Linux (NixOS)
- KDE Frameworks Version: 6.x
- Qt Version: 6.11

**ADDITIONAL INFORMATION**

The issue is in `addons/openlink/matchers.h` (`adjustLink()`). A fix that
repeatedly strips unbalanced trailing ")" characters (and other trailing
punctuation like `'` `"` `.` `>`) resolves this, including for nested markdown
constructs like `[text](url)` inside parentheses.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to