fix: decode support attachment file paths before uploading - #26008
Open
jkmassel wants to merge 1 commit into
Open
fix: decode support attachment file paths before uploading#26008jkmassel wants to merge 1 commit into
jkmassel wants to merge 1 commit into
Conversation
Support attachments are handed to wordpress-rs as filesystem paths, which it opens directly. URL.path() percent-encodes by default, so an attachment whose filename needs encoding produced a path that doesn't exist on disk and failed the whole ticket with MediaFileNotFound. Same shape as the media upload fix in #26005, in the other two params types that take file paths.
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 34432 | |
| Version | PR #26008 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | e9ce5be | |
| Installation URL | 1aivg5c5nah60 |
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 34432 | |
| Version | PR #26008 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | e9ce5be | |
| Installation URL | 448gc5rudbp4g |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes a bug where a support ticket or reply fails to send if an attached screenshot's filename needs percent-encoding — a space is enough.
Same defect as #26005, in the other two
wordpress-rsparams types that carry filesystem paths. Found by sweeping the codebase for the shape after that PR.Summary
URL.path()percent-encodes by default, unlike the legacyurl.pathproperty, which returns a decoded path.CreateSupportTicketParamsandAddMessageToSupportConversationParamsboth passed the encoded form asattachments, sowordpress-rslooked for files that don't exist on disk.Screen Shot 2026-09-08 at 10.31.15.png.Root Cause
WordPress/Classes/ViewRelated/NewSupport/SupportDataProvider.swift: both call sites built the attachment list with
attachments.map { $0.path() }.Those strings are filesystem paths, not URL components. In
wordpress-rsthey becomeMultipartFormFile.file_path— the same struct fieldMediaCreateParams.filePathfeeds — andSafeRequestExecutoropens each one directly:The filename is not app-generated.
ScreenshotPicker.swiftbuilds the attachment URL asdirectory.appendingPathComponent(received.file.lastPathComponent). The directory is app-generated —URL.cachesDirectoryplus a UUID — but the last component is copied verbatim from the file PhotosUI exports, which preserves the asset's original filename.The failure takes the whole request with it.
SupportFormcatches and shows an error alert, so a user attaching a screenshot to report a bug can't file the report.The encoding is wider than spaces
path()escapes non-ASCII too, which puts non-English filenames in scope:Fix
WordPress/Classes/ViewRelated/NewSupport/SupportDataProvider.swift: added an initializer to each params type that takes
attachmentURLs: [URL]and owns the conversion, so the call sites pass URLs and can't reintroduce the encoded form. MirrorsMediaCreateParams.init?(media:)from #26005.Test plan
SupportAttachmentFilePathTests— six cases across both params types: a filename with a space, one with a%, one non-ASCII, controls needing no encoding, and an empty attachment list.Screen%20Shot%201.png,cafe%CC%81.png), and that the three controls pass either way.WordPressTest/SupportAttachmentFilePathTests— 6/6 pass on an iOS 26.4 simulator.Not device-verified. The one link not confirmed by reading code is whether PhotosUI's exported
lastPathComponentretains the space in practice — everything upstream and downstream of that is.Notes
Modules/Sources/WordPressMediaLibrary/Upload/UploadSourceMaterializer.swiftalready buildsMediaCreateParams(filePath: destURL.path)with the decoded property at five sites, so the newer media library was never affected.Related issues
MediaCreateParamsFollow-up
The conversion belongs in the library, not here — Automattic/wordpress-rs#1623 adds
attachmentURLs: [URL]initializers to both params types.The app pins
wordpress-rsatexact: "0.8.0"and can't consume that until it ships and the app bumps, so the extensions in this PR stand in until then. When the app next bumps the dependency, delete them and passattachmentURLs:straight through.