URL_REGEX doesn't match URLs in markdown link syntax
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 62/100
Línea de trabajo
Comience con URL_REGEX_NO_MODIFIERS en lib/public/IURLGenerator.php y extractReferences() en lib/private/Collaboration/Reference/ReferenceManager.php. Compruebe los ejemplos de URL simples y de enlaces Markdown del issue, y después verifique que la extracción siga procesando las URL existentes y también devuelva las URL incluidas en la sintaxis de enlace Markdown; revise core/src/OCP/comments.js por la preocupación de sincronización mencionada.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- PHP
- Estrellas
- 37k
- Forks
- 5.3k
- Merge medio
- 1 d 23 h
- PR fusionados (30 d)
- 680
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nextcloud/server
-
[Bug]: SnowflakeGenerator passes arguments in wrong order to ISequence, causing duplicate IDs in Nextcloud 35Posiblemente ocupada @backportbot la tomó hace 2 días. Abierto0. Needs triage 35-feedback bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
nextcloud/server#65434 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
0. Needs triage 35-feedback bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
34-feedback
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Add a default limit to the results of the `occ taskprocessing:list` commandPosiblemente ocupada @Sahas2711 la tomó hace 6 días. Abiertoenhancement feature: TaskProcessing good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
nextcloud/server#65243 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
1. to develop technical debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
Todos los issues de nextcloud/server
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
woocommerce/woocommerce-google-analytics-integration#699 ·
Los mantenedores suelen responder en 1 día
-
Sidebar highlights two items when plugin routes share a prefix (/plugin/foo and /plugin/foo-bar)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
getgrav/grav-plugin-admin2#195 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 60/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ProfessionalWiki/NeoWiki#1675 ·
Los mantenedores suelen responder en 1 día
-
Incorrect documentationAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100