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

Error in form validation if the action url is from the same host #1349

Closed
ricardobrg opened this issue Aug 22, 2018 · 3 comments
Closed

Error in form validation if the action url is from the same host #1349

ricardobrg opened this issue Aug 22, 2018 · 3 comments
Milestone

Comments

@ricardobrg
Copy link
Contributor

ricardobrg commented Aug 22, 2018

When the action url is from the same host, the $node->getAttribute( 'action' ) return a relative URL instead of full URL. I could not find why it happens yet, but the AMP_Form_Sanitizer doesn't add the server host to action-xhr and amp-form validation fails with the following error:

log.js:342 Uncaught (in promise) Error: form action-xhr must start with "https://" or "//" or be relative and served from either https or from localhost. Invalid value: /produtos/barra-p-cortina-110x200cm-ck912/?amp&add-to-cart=2856&_wp_amp_action_xhr_converted=1​​​

Apart of full URL to relative URL convertion, I believe that a user can have problems while trying to add a regular form with relative URLs. That's why I think it's important to sanitizer detect that and format the URL.

@westonruter
Copy link
Member

Good catch. I see you're working on a PR?

@ricardobrg
Copy link
Contributor Author

@westonruter I did the PR fae8ab9 with the patch I'm using, but didn't do any further debug. It solves the problem when the original form have relative paths, but it doesn't handle the issue of $node->getAttribute( 'action' ) returning relative paths instead of full URLs when the host is the same.

Should I use the SVN repository instead for PRs?

ricardobrg added a commit to ricardobrg/amp-wp that referenced this issue Aug 22, 2018
Detect if action URL in the form doesn't start with http(s) and format it properly.
@westonruter
Copy link
Member

Should I use the SVN repository instead for PRs?

No, please open a pull request on GitHub: develop...ricardobrg:patch-1

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

No branches or pull requests

3 participants