URL_REGEX rejects URLs containing square brackets in query parameters — no reference/link preview extracted
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in lib/public/IURLGenerator.php at URL_REGEX_NO_MODIFIERS, then trace how the references extraction endpoint uses it. Reproduce the supplied POST request and verify that URLs containing literal square brackets are extracted and resolved, while existing URL cases continue to work.
Written by the indexing model from the issue text.
Description
Issue Description
Component: OCP\IURLGenerator::URL_REGEX / OC\Collaboration\Reference\ReferenceManager::extractReferences()
Current behavior:
URLs containing literal square brackets — typically PHP-style array query parameters like ?c[menu]=Overview — are not extracted as references at all. Messages in Talk (and any other app using the references API) render such links as plain text with no rich preview, even when a registered IReferenceProvider would match and resolve them.
// lib/public/IURLGenerator.php
public const URL_REGEX_NO_MODIFIERS = '(\s|\n|^)(https?:\/\/)([-A-Z0-9+_.]+(?::[0-9]+)?(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)';
Two properties of this pattern combine to reject the URL entirely rather than merely truncating it:
[and]are not in the path/query character class, and- the match must be terminated by
(\s|\n|$)— so when the scan hits[, the required whitespace boundary can't be satisfied and the whole candidate fails.
Steps to reproduce:
POST /ocs/v2.php/references/extract?format=json
{"text": "see https://example.com/pages/UI.php?operation=details&class=VirtualMachine&id=2904&c[menu]=ConfigManagementOverview please", "resolve": true}
Result: "references": [] — nothing extracted. The same URL without &c[menu]=…, or with the brackets percent-encoded (c%5Bmenu%5D), extracts and resolves correctly.
Expected behavior:
The URL should be extracted (with the brackets included), matching what browsers, GitHub, Slack, and other linkifiers do.
Real-world impact:
Applications like iTop (ITSM) append UI-state parameters such as &c[menu]=ConfigManagementOverview to their detail-page URLs. Browsers show the decoded form in the address bar, so that is what users copy and paste into Talk. Any reference provider app (e.g. integration_itop) is never consulted because extraction fails one layer above it — and there is no extension point for apps to work around this.
Strictly speaking, RFC 3986 requires brackets in a query component to be percent-encoded, so such URLs are technically non-compliant — but they are what real applications emit and real browsers display, and leniency here matches the de-facto behavior of every mainstream URL detector.
Suggested fix:
Add \[\] to the path/query character class:
public const URL_REGEX_NO_MODIFIERS = '(\s|\n|^)(https?:\/\/)([-A-Z0-9+_.]+(?::[0-9]+)?(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()\[\]]*)*)(\s|\n|$)';
One trade-off to decide: with this change, a URL written inside markdown link syntax [label](https://…) could consume a trailing )] — but the current pattern already includes () in the character class, so that ambiguity exists today and is tracked separately.
Related (not duplicates): #55849 / PR #55850 concern the same constant but a different boundary problem (markdown ]( prefix); this issue is about the character class rejecting brackets inside the URL itself.
Nextcloud version: reproduced on 34.0.2
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d
- Merged PRs (30d)
- 725
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nextcloud/server
-
3. to review
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
0. Needs triage 33-feedback bug feature: dashboard feature: files feature: theming needs info
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
.htaccess whitelist missing .json/.ftl → files_pdfviewer locale 404s, PDF viewer stuck in English Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
0. Needs triage 34-feedback bug
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
All issues in nextcloud/server
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
coollabsio/coolify#11927 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100