Skip to content

Preserve multiline settings when saving resource hint fields #95

@mehul0810

Description

@mehul0810

Finding

The React settings save flow sends JSON payloads through perform_save_settings. The server currently cleans the decoded payload recursively before it looks up field definitions, so textarea fields can lose their multiline shape before field-specific sanitization runs.

Impact

Resource hint fields such as DNS Prefetch and Preconnect are intended to support one value per line. If newlines are collapsed before the final sanitizer/split step, saved settings can be merged into a single invalid value and the frontend output becomes unreliable.

Suggested implementation

  • Decode the JSON payload, then look up each field definition before choosing the sanitizer.
  • Use sanitize_textarea_field() for textarea fields before converting newline-separated values into arrays.
  • Keep existing perform_settings option keys and saved value shape compatible.
  • Keep masked secret handling intact.

Acceptance criteria

  • Saving multiple DNS Prefetch values preserves one entry per line.
  • Saving multiple Preconnect values preserves one entry per line.
  • Existing single-line values continue to save as expected.
  • Masked secret placeholders still preserve the existing stored secret.
  • Add focused PHPUnit or Playwright coverage for multiline settings saves.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: admin-uiWordPress admin screens, settings UI, notices, onboarding, or admin bar UX.area: performancePerformance-sensitive behavior, page weight, caching, preloading, or resource hints.area: settingsSettings schema, storage contracts, migration, import/export, and validation.bugConfirmed or likely defect affecting runtime behavior, UX, compatibility, or data handling.priority: mediumUseful or user-impacting work that should be planned but is not blocking now.risk: backward-compatibilityTouches public data, options, hooks, migrations, or established behavior.status: in-progressWork has a branch, PR, or active release branch implementation path.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions