Skip to content

Conversation

@davidperezgar
Copy link
Member

Description

Fixes #1150 — PayPal donation URLs with complex query strings are now correctly recognized as valid.

The donate link validation incorrectly flagged valid PayPal donation URLs as invalid when they contained URLs in query parameters (e.g., return=https://wordpress.org/plugins/my-plugin/).

Changes

  • Updated is_valid_url() method (includes/Traits/URL_Utils.php):

    • Replaced strict filter_var() validation with a more lenient approach using wp_parse_url()
    • Added proper handling for when wp_parse_url() returns false or non-array values
    • Fixed duplicated protocol detection to only check the URL portion before the query string (?), preventing false positives when URLs appear in query parameters
    • Improved host validation to allow valid characters (alphanumeric, dots, hyphens, underscores)
  • Added test cases (tests/phpunit/tests/Traits/URL_Utils_Tests.php):

  • Added integration test (tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php):

    • Added test_run_with_valid_paypal_donate_link() to verify the full check flow
    • Created test plugin test-plugin-plugin-readme-valid-paypal-donate with a valid PayPal donation URL

Benefits

  • PayPal donation URLs with complex query strings are now correctly validated
  • Reduces false positives for valid donation links
  • Maintains security by still detecting truly invalid URLs and duplicated protocols
  • Better handling of URLs that contain other URLs in query parameters

Checklist

  • Code follows WordPress Coding Standards
  • Self-reviewed the code
  • Added necessary comments
  • No new linter errors
  • Added test cases to prevent regression
  • All existing tests pass
  • New tests pass

@davidperezgar davidperezgar linked an issue Jan 8, 2026 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: davidperezgar <davidperez@git.wordpress.org>
Co-authored-by: ernilambar <nilambar@git.wordpress.org>
Co-authored-by: frantorres <frantorres@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@davidperezgar davidperezgar changed the title Fix issue Fix PayPal donation URL validation for complex query strings Jan 8, 2026
@davidperezgar davidperezgar added this to the 1.9.0 milestone Jan 8, 2026
@ernilambar ernilambar force-pushed the 1150-donate-url-incorrectly-flagged-as-invalid branch from e468afc to ab0f628 Compare January 9, 2026 08:03
@davidperezgar davidperezgar merged commit bb4326d into trunk Jan 10, 2026
27 checks passed
@davidperezgar davidperezgar deleted the 1150-donate-url-incorrectly-flagged-as-invalid branch January 10, 2026 12:48
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.

Donate URL incorrectly flagged as invalid

4 participants