URL_REGEX doesn't match URLs in markdown link syntax
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
lib/public/IURLGenerator.php の URL_REGEX_NO_MODIFIERS と、lib/private/Collaboration/Reference/ReferenceManager.php の extractReferences() から始めてください。issue にあるプレーン URL と Markdown リンクの例を確認し、抽出処理が既存の URL を引き続き処理できること、さらに Markdown リンク構文で囲まれた URL も返すことを検証してください。言及されている同期に関する懸念については core/src/OCP/comments.js を確認してください。
索引モデルが issue の本文から書いたものです。
説明
Issue Description
Component: OCP\IURLGenerator::URL_REGEX / Reference extraction in ReferenceManager
Current Behavior:
The URL_REGEX pattern used by ReferenceManager::extractReferences() fails to match URLs when they're embedded in markdown link syntax:
// lib/public/IURLGenerator.php
public const URL_REGEX_NO_MODIFIERS = '(\s|\n|^)(https?:\/\/)([-A-Z0-9+_.]+(?::[0-9]+)?(?:\/[-A-Z0-9+&@#%?=~_|\!:,.;()]*)*)(\s|\n|$)';
The regex requires whitespace/newline before the URL ((\s|\n|^)), which doesn't match markdown syntax where URLs are preceded by ](.
Test Case:
Plain URL (works):
"Check https://github.com/nextcloud/server/issues/55845 for details"
✅ Extracted: https://github.com/nextcloud/server/issues/55845
Markdown link (fails):
"Check [GH #55845](https://github.com/nextcloud/server/issues/55845) for details"
❌ Extracted: (nothing)
Root Cause:
In lib/private/Collaboration/Reference/ReferenceManager.php line 53:
public function extractReferences(string $text): array {
preg_match_all(IURLGenerator::URL_REGEX, $text, $matches);
// ...
}
The regex pattern doesn't account for markdown link syntax [label](url) where the URL is preceded by ]( instead of whitespace.
Impact:
Reference providers (GitHub, GitLab, Zammad, custom integrations) don't generate rich previews when users paste markdown-formatted links, forcing users to paste plain URLs which reduces text readability.
Affected Use Cases:
[GH #55845](https://github.com/nextcloud/server/issues/55845)- GitHub issues[Ticket #12345](https://support.example.com/ticket/12345)- Support tickets[PROJ-123](https://jira.example.com/browse/PROJ-123)- JIRA issues- Any markdown link in Text app, Talk, or Comments
Proposed Solution:
Update URL_REGEX_NO_MODIFIERS to also match URLs preceded by markdown syntax:
public const URL_REGEX_NO_MODIFIERS = '(\s|\n|^|\]\()(https?:\/\/)([-A-Z0-9+_.]+(?::[0-9]+)?(?:\/[-A-Z0-9+&@#%?=~_|\!:,.;()]*)*)(\s|\n|$|\))';
// ^^^^ added markdown start ^^^ added closing paren
Alternative Solution:
Strip markdown syntax before URL extraction:
public function extractReferences(string $text): array {
// Strip markdown link syntax: [label](url) → url
$text = preg_replace('/\[([^\]]+)\]\(([^)]+)\)/', ' $2 ', $text);
preg_match_all(IURLGenerator::URL_REGEX, $text, $matches);
// ...
}
Backward Compatibility:
- Existing plain URL extraction continues to work
- New: Markdown links also extracted
- No breaking changes for reference providers
Related Code:
lib/public/IURLGenerator.php- URL_REGEX definitionlib/private/Collaboration/Reference/ReferenceManager.php- extractReferences()- Frontend:
core/src/OCP/comments.js(mentioned in comments as needing sync)
Nextcloud Version:
- Affects: All versions with Reference Provider system (NC 25+)
- Tested on: Nextcloud 30
Workaround:
Users must paste plain URLs without markdown formatting to trigger rich previews.
- 主要言語
- PHP
- スター
- 37k
- フォーク
- 5.3k
- 平均マージ
- 1日 20時間
- マージ済み PR(30日)
- 720
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud/server のほかの issue
-
0. Needs triage 35-feedback bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
34-feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
Add a default limit to the results of the `occ taskprocessing:list` command対応中かも @Sahas2711 が 2 日前に担当しました。 オープンenhancement feature: TaskProcessing good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
1. to develop technical debt
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
0. Needs triage 35-feedback bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
nextcloud/server の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
components-web-app/api-components-bundle#403 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
mollie/PrestaShop#1566 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
components-web-app/docs#193 ·
-
Python 3.15 support対応中かも @amnesiaof が今日担当しました。 オープンL: python L: python:uv
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
dependabot/dependabot-core#16524 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
crazy-goat/rabbit-stream#830 ·
メンテナーはふだん 1 日以内に返信