Skip to content

fix(previews): validate URL input #243

Closed

Description

@ahuseyn

Right now any text can be inserted into Preview URL input. Only a valid URL should be allowed.

Image

Activity

  1. self-assigned this
    on Jun 9, 2025
  2. colinmurphy commented on Jun 9, 2025

    @colinmurphy
    Member

    @ahuseyn I will look at this. I am currently writing tests for settings so I should be able to fix this. Currently we just sanitize the text field.

  3. colinmurphy commented on Jun 9, 2025

    @colinmurphy
    Member

    @ahuseyn We can add a new field called URL_Text_Field in the PR #241

  4. moved this from 🆕 Backlog to 🔖 Ready for Development in Headless OSSon Jun 9, 2025
  5. colinmurphy commented on Jun 10, 2025

    @colinmurphy
    Member

    @ahuseyn

    Just a heads up with this issue when you try and escape the URL

    https://example.com/?preview=true&name={slug}

    becomes

    https://example.com/?preview=true&name=slug which is problematic for the parameter resolver.

    So we probably need to check that the URL has a valid HTTP protocol too rather than escaping the URL (sanitize_url WP function)

  6. ahuseyn commented on Jun 11, 2025

    @ahuseyn
    ContributorAuthor

    @colinmurphy thanks for the clarification 🙂.

    Sanitization is important, but for this ticket we should check if URL is valid and reject if not as you said. This one looks good for the job.

    On the frontend we need to add URL type to the input, so user can't accidentally put wrong URL in the first place 🙂.

  7. colinmurphy commented on Jun 11, 2025

    @colinmurphy
    Member

    @colinmurphy thanks for the clarification 🙂.

    Sanitization is important, but for this ticket we should check if URL is valid and reject if not as you said. This one looks good for the job.

    On the frontend we need to add URL type to the input, so user can't accidentally put wrong URL in the first place 🙂.

    Thanks @ahuseyn I will check that out :)

  8. colinmurphy commented on Jun 11, 2025

    @colinmurphy
    Member

    Sorry we can also update the URL input type too to ensure the input is a URL :)

  9. moved this from 🔖 Ready for Development to 👀 In review in Headless OSSon Jun 13, 2025
  10. colinmurphy commented on Jun 13, 2025

    @colinmurphy
    Member

    @ahuseyn

    This should be fixed now. It might be worth double checking :)

  11. colinmurphy commented on Jun 16, 2025

    @colinmurphy
    Member

    @ahuseyn Going to move into sprint 13 as we should make sure we add a e2e test for this.

  12. colinmurphy commented on Jun 24, 2025

    @colinmurphy
    Member

    Closing as tested with PHPUnit tests and also manually . I cannot find any issues.

  13. moved this from 👀 In review to ✅ Closed in Headless OSSon Jun 24, 2025
  14. ahuseyn commented on Jun 24, 2025

    @ahuseyn
    ContributorAuthor

    I've added an e2e test for this validation: 06dc013

  15. colinmurphy commented on Jun 24, 2025

    @colinmurphy
    Member

    Thanks @ahuseyn ❤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Area] PreviewsIssues for the HWP Previews plugin[Type] BugAn existing feature is broken

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions