Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent validation errors for URLs with leading or trailing spaces #4166

Merged
merged 9 commits into from
Jan 24, 2020

Commits on Jan 23, 2020

  1. Allow a URL to have a leading space without a validation error

    As Weston found, something like:
    <a href=" https://wp.org"> would have
    a validation error.
    kienstra committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    fe3acd0 View commit details
    Browse the repository at this point in the history
  2. Replace 2 calls of trim() with longer regex in parse_protocol()

    Those trim( $url ) calls were passed
    to parse_protocol().
    So do something similar inside parse_protocol(),
    don't match leading space.
    kienstra committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    9bd24e6 View commit details
    Browse the repository at this point in the history
  3. As there's now a capturing group, remove lookahead

    There is a matching group of ([^/]),
    so there probably isn't a need for the lookahead.
    kienstra committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    a01b51f View commit details
    Browse the repository at this point in the history
  4. Revert change to regex, in favor of trimming before it's passed

    Instead of changing this,
    simply trim() the URL before passing it
    to parse_protocol()
    kienstra committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    761981e View commit details
    Browse the repository at this point in the history
  5. Move urldecode() lower in the function

    As Weston mentioned, there might not be a need
    for it to run earlier.
    kienstra committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    bd4f45f View commit details
    Browse the repository at this point in the history
  6. Remove test case that is no longer handled

    parse_protocol() no longer trims
    space on its own.
    kienstra committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    c703052 View commit details
    Browse the repository at this point in the history

Commits on Jan 24, 2020

  1. Add a new method to normalize URLs

    Use this instead of trim()
    for the URLs in attributes.
    kienstra committed Jan 24, 2020
    Configuration menu
    Copy the full SHA
    911602d View commit details
    Browse the repository at this point in the history
  2. Use suggested normalization, update tests

    Use this from the AMP validator,
    instead of a simple regex, also use trim().
    kienstra committed Jan 24, 2020
    Configuration menu
    Copy the full SHA
    f193019 View commit details
    Browse the repository at this point in the history
  3. Revert change in some tests, as they're not needed anymore

    The behavior of the new parse_url_ method
    is changed, so these can change back.
    kienstra committed Jan 24, 2020
    Configuration menu
    Copy the full SHA
    92bb4e6 View commit details
    Browse the repository at this point in the history