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

Comments

3 participants
@ricardobrg
Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

commented Aug 22, 2018

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

@ricardobrg

This comment has been minimized.

Copy link
Contributor Author

commented Aug 22, 2018

@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

Fix ampproject#1349. Detect http(s) and format it.
Detect if action URL in the form doesn't start with http(s) and format it properly.
@westonruter

This comment has been minimized.

Copy link
Member

commented Aug 22, 2018

Should I use the SVN repository instead for PRs?

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

@kienstra kienstra added this to the v1.0 milestone Dec 4, 2018

@kienstra kienstra added this to Ready for Merging in v1.0 Dec 4, 2018

@kienstra kienstra moved this from Ready for Merging to In Production in v1.0 Dec 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.