Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

URL_REGEX doesn't match URLs in markdown link syntax

オープン 初心者向け
#55,849 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@LexioJ がすでに取り組んでいます。

2025年10月18日 から。

  • #55850 @LexioJ による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
php
領域
backend

調査の方向性

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 の本文から書いたものです。

説明

3. to review 33-feedback bug
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 definition
  • lib/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

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nextcloud/server のほかの issue

nextcloud/server の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。