Repository navigation
Only delete, export and store media files inside the uploads folder - #2242
Conversation
🔍 WordPress Plugin Check Report
📊 Report
|
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
mismatched_plugin_name | Plugin name "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" is different from the name declared in plugin header "GoDAM". |
0 |
trademarked_term | The plugin name includes a restricted term. Your chosen plugin name - "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" - contains the restricted term "wordpress" which cannot be used at all in your plugin name. |
📁 assets/build/css/main.css (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedStylesScope | This style is being loaded in all contexts. |
📁 assets/src/libs/analytics.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/10/26/hello-world/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
📁 assets/build/js/main.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/10/26/hello-world/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check
- Deleting a media item removes the transcoded files and thumbnails listed in its meta only when they are files inside the uploads folder. Any other path in the meta is skipped. - rtgodam_media_thumbnails and rtgodam_media_transcoded_files are protected meta, so XML-RPC custom fields and the custom fields box no longer write them. GoDAM keeps saving them with update_post_meta(). - create-media-entry stores a bare file name as the media item's file, with no directories, and only saves the url, mpd_url and hls_url values that are public http(s) addresses. - The folder ZIP export adds only files that are inside the uploads folder. - Add PHPUnit tests for each of the above.
63d4659 to
0caa100
Compare
|
Tested together with the other five 2.5.1 PRs on a hosted test site connected to production GoDAM Central. Full table and all recordings: https://github.com/rtCamp/godam-plugin-wp/issues/68 (recordings are in the rtCamp Test media library; sign in to watch). Tested commit
|
elifvish
left a comment
There was a problem hiding this comment.
Low, consistency: the new public-URL check covers url, mpd_url and hls_url, but icon, thumbnail_url and preview_pdf_url from the same request are still saved as meta with only esc_url_raw(). Nothing fetches them server-side today, so it is not a request-forgery path, just the same rule half-applied. Adding them to the loop is enough (see inline).
Worth knowing: wp_http_validate_url() returns false when the host does not resolve, so a DNS hiccup on the WordPress host shows up as "Invalid media URL" in the GoDAM tab.
Verification
- Head tested:
0caa100513. PHPUnit on this PR's head: 663/663 OK. - All seven 2.5.1 PRs merged onto
main(no conflicts): PHPUnit 915/915, Jest 690/690,build:prodOK. - Playwright API checks against that build on a local WordPress 7.1.3 site: 7/7 for this PR.
- Not covered: Folder ZIP export end to end (needs Action Scheduler run); covered by code reading and unit tests; Offloaded (stream-wrapper) uploads: no such setup locally.
Screenshots and a recording of the local run are available on request.
Review: approvable ✅Reviewed at high effort with a focus on the path-traversal surface (delete / ZIP export / store). The fix is solid and thoroughly tested.
Only optional defense-in-depth nits, none blocking:
LGTM to merge as part of 2.5.1. |
What changes
GoDAM now only deletes, exports and stores media files inside the WordPress uploads folder.
admin/godam-transcoder-functions.php): the transcoded files and thumbnails listed in the item's meta are deleted only when they resolve (realpath()) to a file inside the uploads folder. Anything else is skipped. New helperrtgodam_get_uploads_file_path(); sites whose uploads live on a stream wrapper get a normalized-path check instead.rtgodam_media_thumbnailsandrtgodam_media_transcoded_filesare now protected (is_protected_meta), so XML-RPC custom fields and the Custom Fields box no longer write them. GoDAM's ownupdate_post_meta()calls are unaffected.inc/classes/rest-api/class-media-library.php):_wp_attached_filekeeps only the bare file name fromfilename(no directories, no.or..). Virtual media has no local file; every reader only uses the name or its extension. The name itself is kept as sent, so the Media Library shows the same file name as before.url,mpd_urlandhls_urlmust be public http or https addresses (wp_http_validate_url(), plus the 169.254.0.0/16 range, which core only refuses from 7.x). Anything else returns 400invalid_urland nothing is created.inc/classes/media-library/class-media-folder-create-zip.php): adds a file only if it is inside the uploads folder, so existing entries with any other stored path are skipped.Testing
Throwaway WordPress (Playground, WordPress 7.1.3, PHP 8.3) with the 2.5.0 release plus these files; Author checks with a real Author login over HTTP; harmless marker files only.
wp.editPostcustom fields for the two GoDAM keys on the Author's own imageadd-meta) for the two keysfilenamecontaining directorieshttpsURLsurl/mpd_url/hls_urlset to loopback, private, link-local orfile://addressesinvalid_url, nothing createdtests/php/MediaFilePathsTest.phpandtests/php/CreateMediaEntryUrlTest.php; full suite OK (663 tests).phpcsclean on every changed file;bin/hook-checkbalance and coverage checks pass.Worth knowing
.localhost would now getinvalid_urlfor virtual media. It can allow its host with core'shttp_request_host_is_externalfilter.wp_http_validate_url()only allows ports 80, 443 and 8080 and does a DNS lookup per URL. GoDAM's CDN URLs use 443.QA:
Issue: rtCamp/godam-plugin-wp#70