Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

URL_REGEX doesn't match URLs in markdown link syntax

Aperta Adatta ai principianti
#55,849 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
php
Ambito
backend

Direzione di ricerca

Inizia con URL_REGEX_NO_MODIFIERS in lib/public/IURLGenerator.php e extractReferences() in lib/private/Collaboration/Reference/ReferenceManager.php. Controlla gli esempi di URL semplice e di link Markdown dell’issue, quindi verifica che l’estrazione continui a gestire gli URL esistenti e restituisca anche gli URL racchiusi nella sintassi dei link Markdown; esamina core/src/OCP/comments.js per quanto riguarda il problema di sincronizzazione menzionato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
PHP
Stelle
36.9k
Fork
5.2k
Merge medio
2g 35m
PR unite (30g)
721

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nextcloud/server

Tutte le issue di nextcloud/server

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.