Repository navigation
fix(deeplink): encode message-id as base64url for deep links - #14023
Conversation
|
Hi @SoleroTG, thanks a lot for the quick fix for #13970! Allowing slashes fixes this case, but Message-IDs can contain other characters that are awkward in a URL path as well. Could you encode the Message-ID (e.g. base64url) when generating the link in the search provider and decode it in Please keep accepting the raw Message-ID as well, so existing links keep working (a raw Message-ID always contains an
$this->urlGenerator->linkToRouteAbsolute('mail.deep_link.open', [
'messageId' => rtrim(strtr(base64_encode($message->getMessageId()), '+/', '-_'), '='),
]),
if (!str_contains($messageId, '@')) {
$messageId = base64_decode(strtr($messageId, '-_', '+/'), true);
if ($messageId === false) {
return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('mail.page.index'));
}
} |
a61f6e6 to
1978bcc
Compare
|
Thanks for the suggestion, @kesselb. That is indeed much cleaner than overriding Symfony's route requirements and avoids all web server / path-segment quirks. I have updated the PR accordingly:
|
1978bcc to
e53ea62
Compare
|
Thank you!
Smaller things:
Assisted by ClaudeCode:claude-opus-5-5 |
RFC 5322 permits characters in Message-IDs (such as slashes, quotes, etc., commonly seen in GitHub notifications or Bugzilla/GitLab messages) that are problematic in URL paths. When generating a deep link in the Unified Search provider (mail.deep_link.open) or copying a direct link, Symfony's UrlGenerator threw an InvalidParameterException or web servers failed to route slashes. Encode Message-IDs using URL-safe base64url via a Base64Url helper in the search provider and envelope menu, and decode it in DeepLinkController::open(). Unencoded Message-IDs are still accepted for backwards compatibility by checking for the mandatory '@' symbol. If a message lacks a Message-ID, the search provider falls back to the direct thread link. Fixes nextcloud#13970 Signed-off-by: SoleroTG <github-29h@solero.quietmail.eu>
e53ea62 to
bee7643
Compare
|
Thanks for the thorough review, @kesselb. All points have been addressed:
|
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
|
/backport to stable5.13 please |
Base64UrlTest, added in nextcloud#14023, was not final, which fails the FinalizeTestCaseClassRector check on main. Assisted-by: ClaudeCode:claude-sonnet-5-5 Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
Summary
Encodes Message-IDs as URL-safe base64url in the Unified Search provider and decodes them in
DeepLinkController::open(), addressing #13970 as suggested in #14023 (comment).Context & Implementation
rtrim(strtr(base64_encode(...), "+/", "-_"), "=")). This eliminates issues with slashes and special characters in the URL path while keeping the route definition clean.DeepLinkController::open()checks!str_contains($messageId, "@")before decoding. Because RFC 5322 Message-IDs always contain@and base64url never does, existing unencoded links continue to work.DeepLinkControllerTest, plus URL generation inFilteringProviderTest.Fixes #13970
Signed-off-by: SoleroTG github-29h@solero.quietmail.eu