You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found out that the AMP validator validates JSON for parse errors, but we are not.
Given this markup:
<scripttype="application/ld+json">{BAD🚫🚫🚫</script><amp-analyticstype="nielsen"><scripttype="application/json">{"vars": {"apid": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","apv": "1.0",
"ap BAD 🚫 🚫 🚫
</script></amp-analytics>
No validation errors are reported by the AMP plugin, and yet the AMP validator does report them:
Such invalid JSON should be sanitized while also reporting a validation error to the user to prevent GSC from alerting users to an error when it crawls next that we can proactively alert them of immediately.
Note that the AMP validator does not yet validate application/ld+json data, but it should after ampproject/amphtml#25610.
One way that this JSON parse error can occur is if JSON contains emoji. See #4318.
Bug Description
I found out that the AMP validator validates JSON for parse errors, but we are not.
Given this markup:
No validation errors are reported by the AMP plugin, and yet the AMP validator does report them:
Such invalid JSON should be sanitized while also reporting a validation error to the user to prevent GSC from alerting users to an error when it crawls next that we can proactively alert them of immediately.
Note that the AMP validator does not yet validate
application/ld+json
data, but it should after ampproject/amphtml#25610.One way that this JSON parse error can occur is if JSON contains emoji. See #4318.
The code needing to be patched here is
AMP_Tag_And_Attribute_Sanitizer::validate_cdata_for_node()
. Note this code will also need to be modified to fix a separate bug with howblacklisted_cdata_regex
is handled, so beware of merge conflicts; see #4319.The logic can be adopted from the
amphtml-validator
here: https://github.com/ampproject/amphtml/blob/e1fd0e15b85e6f80f5d6382600b0765875d37b23/validator/engine/validator.js#L6226-L6237Note the
INVALID_JSON_CDATA
error code. The error message should be: “The script tag contains invalid JSON that cannot be parsed.”Related support topics:
Expected Behaviour
Steps to reproduce
Screenshots
Additional context
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
The text was updated successfully, but these errors were encountered: