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

Initial whitespace in href causes validation error #4117

Closed
westonruter opened this issue Jan 16, 2020 · 4 comments · Fixed by #4166
Closed

Initial whitespace in href causes validation error #4117

westonruter opened this issue Jan 16, 2020 · 4 comments · Fixed by #4166
Labels
Bug Something isn't working QA passed Has passed QA and is done Sanitizers Validation
Milestone

Comments

@westonruter
Copy link
Member

Bug Description

Given HTML like this:

<p>Powered by <a href=" https://wordpress.org/">WordPress</a></p>

A INVALID_URL_PROTOCOL validation error is raised:

image

Notice the initial whitespace before the URL in the href attribute. The link works properly in the non-AMP version, and the above markup causes no validation error in the AMP validator.

So it seems the URL needs to be trimmed before checking whether it is valid.

Expected Behaviour

Steps to reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Screenshots

Additional context

  • WordPress version:
  • Plugin version:
  • Gutenberg plugin version (if applicable):
  • AMP plugin template mode:
  • PHP version:
  • OS:
  • Browser: [e.g. chrome, safari]
  • Device: [e.g. iPhone6]

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation brief

QA testing instructions

Demo

Changelog entry

@kienstra
Copy link
Contributor

Implementation Brief

It looks like trim( $url ) will fix this, but adding test cases for this will also be important.

@kienstra
Copy link
Contributor

Testing Steps

  1. Create a new post
  2. Add a Custom HTML block with:
<p><a href=" https://foo.com">Leading Space In href</a></p>
<p><a href="https://foo.com ">Trailing Space In href</a></p>
  1. Save, and go to the front-end of the AMP URL
  2. Expected: there's no validation error

@csossi
Copy link

csossi commented Jan 27, 2020

Verified in QA

@kienstra
Copy link
Contributor

Thanks, Claudio!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working QA passed Has passed QA and is done Sanitizers Validation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants