Skip to content

feat: sanitize CLOUDINARY_URL= prefix and add inline format hint in w…#1158

Open
Udilh wants to merge 1 commit intocloudinary:masterfrom
Udilh:feature/sanitize-connection-url-and-inline-error
Open

feat: sanitize CLOUDINARY_URL= prefix and add inline format hint in w…#1158
Udilh wants to merge 1 commit intocloudinary:masterfrom
Udilh:feature/sanitize-connection-url-and-inline-error

Conversation

@Udilh
Copy link

@Udilh Udilh commented Mar 24, 2026

…izard

  • Add Connect::sanitize_connection_url() — strips the CLOUDINARY_URL= prefix (case-insensitive) and trims surrounding whitespace, covering the common copy-paste pattern from the Cloudinary dashboard.
  • Wire the new method into verify_connection(), rest_test_connection(), upgrade_connection(), and maybe_connection_string_constant(), replacing the previous case-sensitive str_replace() calls.
  • Wizard PHP: add #connection-format-hint

    beneath the error indicator so users see the expected URL format inline without leaving the page.

  • Wizard JS: expose formatHint in the connection object; show the hint in showError(), hide it in showSuccess() and on each new keystroke; upgrade the prefix-strip regex from literal string to /^CLOUDINARY_URL=/i with a .trim() so leading/trailing whitespace is also handled client-side.
  • Add PHPUnit 9 test suite (tests/php/test-class-connect.php) covering sanitize_connection_url() (8 cases) and CLOUDINARY_VARIABLE_REGEX (6 cases), plus 3 sanitize-then-validate integration tests. Bootstrap stubs the minimal WP functions so tests run without a WP installation.
  • Add phpunit/phpunit ^9.6 to composer require-dev and create phpunit.xml.dist.

Fixes #123

Approach

  • Describe the approach and the suggested implementation.

QA notes

  • Detail the steps needed to verify the PR.

…izard

- Add Connect::sanitize_connection_url() — strips the CLOUDINARY_URL=
  prefix (case-insensitive) and trims surrounding whitespace, covering
  the common copy-paste pattern from the Cloudinary dashboard.
- Wire the new method into verify_connection(), rest_test_connection(),
  upgrade_connection(), and maybe_connection_string_constant(), replacing
  the previous case-sensitive str_replace() calls.
- Wizard PHP: add #connection-format-hint <p> beneath the error indicator
  so users see the expected URL format inline without leaving the page.
- Wizard JS: expose formatHint in the connection object; show the hint in
  showError(), hide it in showSuccess() and on each new keystroke; upgrade
  the prefix-strip regex from literal string to /^CLOUDINARY_URL=/i with
  a .trim() so leading/trailing whitespace is also handled client-side.
- Add PHPUnit 9 test suite (tests/php/test-class-connect.php) covering
  sanitize_connection_url() (8 cases) and CLOUDINARY_VARIABLE_REGEX
  (6 cases), plus 3 sanitize-then-validate integration tests. Bootstrap
  stubs the minimal WP functions so tests run without a WP installation.
- Add phpunit/phpunit ^9.6 to composer require-dev and create phpunit.xml.dist.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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