Skip to content

Refactor download URL extraction logic#38

Open
TDannhauer wants to merge 1 commit intoFRAMEWORK_6_0from
fix/mobile-attachment-download
Open

Refactor download URL extraction logic#38
TDannhauer wants to merge 1 commit intoFRAMEWORK_6_0from
fix/mobile-attachment-download

Conversation

@TDannhauer
Copy link
Copy Markdown
Contributor

Summary

Fix smartmobile attachment links to open/download reliably on mobile by avoiding AJAX navigation and handling non-string download_url payloads.

Context / Problem

In smartmobile mode, opening attachments (for example PDFs) could fail with blank/error pages.
Root cause: attachment links were sometimes built from a non-string download_url value (serialized object), producing invalid URLs such as [object Object]. Also, attachment requests should bypass jQuery Mobile AJAX navigation for binary responses.

Changes

vendor/horde/imp/js/smartmobile.js

In showAttachments():

  • Force direct navigation for attachment links:
    • rel: 'external'
    • data-ajax: 'false'
  • Add robust URL normalization:
    • Use v.download_url when it is a valid string.
    • If not, extract href from existing v.download HTML as fallback.
    • Skip rendering link when no valid URL can be resolved.
  • Add a short inline comment documenting why attachments must bypass AJAX navigation.

Why this approach

  • Binary payloads (PDF/images/etc.) should be handled via normal HTTP navigation/download, not page-fragment AJAX routing.
  • Fallback extraction from v.download keeps compatibility with payload variants where URL objects are serialized unexpectedly.
  • Keeps fix localized to smartmobile attachment rendering without changing backend behavior.

Behavioral Impact

  • Smartmobile attachment links now resolve to valid URLs even when download_url is not a string.
  • PDF and other attachment downloads/views open correctly on mobile.
  • Prevents malformed URLs like /imp/[object Object].

Test Plan

  • Open an email with PDF attachment in smartmobile mode and verify it opens/downloads.
  • Repeat with image and generic binary attachments.
  • Confirm attachment links no longer contain [object Object] in Network tab.
  • Confirm dynamic mode behavior remains unchanged.

Updated download URL handling to support various formats and ensure valid URLs are used.
@TDannhauer TDannhauer requested a review from ralflang May 5, 2026 10:54
@TDannhauer TDannhauer mentioned this pull request May 5, 2026
4 tasks
@TDannhauer
Copy link
Copy Markdown
Contributor Author

fixes together with PR horde/base#83 issue #37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant