URL_REGEX doesn't match URLs in markdown link syntax
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
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
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.
- Lingua principale
- PHP
- Stelle
- 36.9k
- Fork
- 5.2k
- Merge medio
- 2g 35m
- PR unite (30g)
- 721
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nextcloud/server
-
SFTP external storage cannot read RSA private key entered in the web form: “Unable to read key”Aperta0. Needs triage 35-feedback bug feature: external storage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
nextcloud/server#64702 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
1. to develop 35-feedback bug feature: encryption (server-side) feature: users and groups
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
nextcloud/server#64685 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
3. to review
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nextcloud/server#64461 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
0. Needs triage 33-feedback bug feature: dashboard feature: files feature: theming needs info
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nextcloud/server#64113 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
files:transfer-ownership fails with "not enough free space" when the target quota is unlimitedAperta0. Needs triage bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
nextcloud/server#64019 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di nextcloud/server
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
sync-en
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
[Area] REST API [Type] Documentation Good First Issue
Difficoltà 1/5 1-3 ore Idoneità per principianti 90/100
WordPress/presence-api#584 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100