amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

amp cache link re-writes can cause validation error

Open dknecht opened this issue 10 years ago • 6 comments

If a page is served from cdn.ampproject.com/c/example.com/test.html and has amp-pixel with relative url <amp-pixel src="/pixel?status=bar"></amp-pixel> it will pass validations on edge but then cause error on page because of http vs https src <amp-pixel src="http://example.com/pixel?status=bar"></amp-pixel>

dknecht avatar Jun 09 '16 17:06 dknecht

@dknecht In this case, the cache appears to have correctly made http determination, which is appropriately blocked. If this page is HTTPs, it should be accessed via cdn.ampproject.com/c/s/example.com/test.html (/c/s/). I'm not sure, however, why this page validates in the first place.

/cc @Gregable

dvoytenko avatar Jun 10 '16 01:06 dvoytenko

@Gregable Slotting in backlog, but feel free to correct/update the milestone as needed

ericlindley-g avatar Jun 15 '16 23:06 ericlindley-g

@dvoytenko, we allow relative URLs in <amp-pixel>, though not http. Changing this constraint breaks a lot of pages.

Gregable avatar Jul 01 '16 22:07 Gregable

@Gregable I see. What happens is that our runtime rules are stricter - they require URL to, at least, contain hostname, but allows protocol-relative URLs. I agree, requiring this now in validator will be difficult as it will invalidate lots of docs that are currently valid (although with nonfunctional amp-pixel). I see two options:

  1. Ask publishers to change and update validator
  2. Allow non-host relative URLs and resolve the absolute URL against the origin. Or, alternatively, we can ask Cache to rewrite the URL for us.

I prefer the second option.

dvoytenko avatar Jul 06 '16 23:07 dvoytenko

Filed an internal b/30000906 against Cache to rewrite pixel URLs against the origin.

dvoytenko avatar Jul 06 '16 23:07 dvoytenko

I believe this is fixed now, please reopen if you find otherwise.

vitaliybl avatar Feb 22 '17 16:02 vitaliybl