In the amp base theme, the amptheme_html_head_alter() is removing ALL script tags that are not pulling from the ampproject cdn url. This gobbles up a bit too much. for example, we need to be able to add AMP metadata with a script tag.

It should first check to see if it even has a src attribute defined, separate from where that source is actually coming from.

Comments

jazzdrive3 created an issue. See original summary.

jazzdrive3’s picture

StatusFileSize
new1.69 KB

This fixes the issue, while also allowing a #value to be populated inside a script tag again.

jazzdrive3’s picture

Status: Active » Needs review
rainbowarray’s picture

StatusFileSize
new1.69 KB
new1.11 KB

Letting through all script elements without a src would open the possibility for a module or theme to add a script element with embedded JS, which isn't allowed as per AMP. This closes that loophole but still allows through the JSON necessary for AMP metadata. If we find other exceptions, we can expand that whitelist, but for now I think this should do the trick.

rainbowarray’s picture

Title: Removing of scripts in head too ambitious » Stop removing AMP metadata JSON script element

  • mdrummond committed 7693c01 on 7.x-1.x authored by jazzdrive3
    Issue #2734535 by mdrummond, jazzdrive3: Stop removing AMP metadata JSON...
rainbowarray’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.