Skip to content

Commit 4fade1d

Browse files
committed
docs: correct the upload validation claims in the GBK processor
Two claims in `isRejectedByFreePlan` were wrong. The comment said GutenbergKit already validates against the site's real `allowedMimeTypes` from `/wp-block-editor/v1/settings`. It does not: that route is provided by the Gutenberg plugin, not WordPress core, so on a site without the plugin the setting stays null and the editor's check passes everything through. Images and videos are left to the server. It also justified the free-plan rejection as beating the server's "untranslated" error. That error is a core `__()` string and is translated — to the site's locale, which need not match the app's. Rest the rejection on what actually holds: it spares an upload certain to fail and reports it in the app's locale.
1 parent f247250 commit 4fade1d

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

WordPress/src/main/java/org/wordpress/android/ui/posts/editor/GBKMediaUploadProcessor.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,22 @@ class GBKMediaUploadProcessor(
142142

143143
/**
144144
* Rejects the one upload class the app can judge better than the server: audio and documents
145-
* on a free WordPress.com plan, where the restriction is a plan entitlement rather than a
146-
* format question, so a localized message beats the server's untranslated error.
145+
* on a free WordPress.com plan, where the restriction is a plan entitlement the app knows
146+
* reliably rather than a format question. Rejecting here spares an upload certain to fail and
147+
* reports it in the app's locale — the server's own message is localized too, but to the
148+
* site's locale, which need not match.
147149
*
148150
* Deliberately narrow. [MediaUtilsWrapper.isMimeTypeSupportedBySitePlan] matches against a
149151
* closed, hand-maintained table ([org.wordpress.android.fluxc.utils.MimeTypes]) that has
150152
* drifted from what WordPress accepts — it has no `image/avif` (core-supported since 6.5), no
151153
* `image/svg+xml`, and no text types at all, and it maps self-hosted to the same document set
152154
* as WP.com paid. Applying it to every upload therefore rejects files the server would store.
153-
* GutenbergKit already validates against the site's real `allowedMimeTypes` from
154-
* `/wp-block-editor/v1/settings` before this delegate runs, so images and videos are left to
155-
* that check and to the server, which are both authoritative where this table is not.
155+
* Images and videos are left to the server, which is authoritative where this table is not.
156+
*
157+
* Nothing screens them before that. GutenbergKit validates uploads against
158+
* `allowedMimeTypes`, but that value reaches it only from `/wp-block-editor/v1/settings`, a
159+
* route the Gutenberg plugin provides and WordPress core does not; without it the setting
160+
* stays null and the check passes everything through.
156161
*
157162
* The free-plan test mirrors [WPMediaUtils.getSitePlanForMimeTypes], which selects
158163
* `WP_COM_FREE` from [SiteUtilsWrapper.onFreePlan] — using `hasFreePlan` here instead would

0 commit comments

Comments
 (0)