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

fix(pagebuilder): Html content type unescapes when GraphQL does not #2283

Merged

Conversation

zetlen
Copy link
Contributor

@zetlen zetlen commented Mar 25, 2020

Description

Due to an apparent regression in M2.3.5, the GraphQL API now passes HTML content (in CMS blocks, anyway) through at least one PageBuilder-related render. The effect is that HTML content nodes, whose content itself was HTML encoded (<div> became &lt;div&gt;), was no longer HTML encoded. This broke the PageBuilder Html content type by stripping all HTML tags from it.

The Html "config aggregator" was using node.textContent to get and unescape its HTML, but when GraphQL has already unescaped it, we must use innerHTML instead. This PR updates the config aggregator with that logic.

Because the bug in MC-32787 may indicate a misconfiguration, the config aggregator logs a message in development mode.

Related Issue

Closes https://jira.corp.magento.com/browse/MC-32787.

Acceptance

Verification Stakeholders

@sirugh
@davemacaulay
@dpatil-magento

Specification

Verification Steps

  1. Set your MAGENTO_BACKEND_URL=<host> a 2.3.4 instance.
  2. yarn run watch:venia
  3. Visit homepage.
  4. Verify it looks normal.
  5. Set your MAGENTO_BACKEND_URL=<host> a 2.3.5 instance
  6. yarn run watch:venia
  7. Visit homepage.
  8. Verify it still looks normal, whereas in develop this formatting is bonkers.
  • I have updated the documentation accordingly, if necessary.
  • I have added tests to cover my changes, if necessary.

@zetlen zetlen added the version: Patch This changeset includes backwards compatible bug fixes. label Mar 25, 2020
davemacaulay
davemacaulay previously approved these changes Mar 25, 2020
jimbo
jimbo previously approved these changes Mar 25, 2020
sirugh
sirugh previously approved these changes Mar 25, 2020
@zetlen zetlen dismissed stale reviews from sirugh, jimbo, and davemacaulay via 1bee42d March 25, 2020 20:02
@zetlen zetlen force-pushed the zetlen/pagebuilder-detect-unescape-MC-32787 branch from e30f3da to 1bee42d Compare March 25, 2020 20:02
@zetlen zetlen changed the base branch from develop to release/6.0 March 25, 2020 20:03
let html;
if (node.dataset.decoded) {
html = node.innerHTML;
if (process.env.NODE_ENV !== 'production') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we remove logs in production bundles anyways - shouldn't need to gate with a condition. If I'm wrong we probably have to go clean up our app :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might, but I just wanted to be explicit. This is a pattern we ought to follow. We may later remove the drop_console in some cases!

@PWAStudioBot
Copy link
Contributor

PWAStudioBot commented Mar 27, 2020

Messages
📖

Access a deployed version of this PR here. Make sure to wait for the "pwa-pull-request-deploy" job to complete.

📖 DangerCI Failures related to missing labels/description/linked issues/etc will persist until the next push or next nightly build run (assuming they are fixed).
📖

Associated JIRA tickets: MC-32787.

Generated by 🚫 dangerJS against dd04fdb

@dpatil-magento
Copy link
Contributor

Works fine. Tested this PR against -

  1. 2.3.5 with core fix.
  2. 2.3.5 without core fix.
  3. 2.3.5 with Core fix and without PB data changes (PWA home page)
  4. 2.3.4
  5. 2.3.4 without PB data changes (PWA home page)

@dpatil-magento dpatil-magento merged commit 0358e01 into release/6.0 Apr 1, 2020
@dpatil-magento dpatil-magento deleted the zetlen/pagebuilder-detect-unescape-MC-32787 branch April 1, 2020 17:36
dpatil-magento added a commit that referenced this pull request Apr 28, 2020
* Removed cart and checkout routes from 6.0 branch. (#2255)

* - Mock version in test so snaps dont fail during releases (#2266)

- Fixup regex to handle line breaks

* [security] minimist >= 1.2.2 (#2267)

* Requires at least minimist 1.2.2 due to security vuln

Signed-off-by: sirugh <[email protected]>

* Switches to yarn and requires minimist 1.2.2 for security vuln

Signed-off-by: sirugh <[email protected]>

* v6.0.0-alpha.1

* v6.0.0-beta.1

* Jimothy/6.0 release notes (#2279)

* Add unsorted PR list

* Add items to separate lists

* Finish organizing PRs in sections

* Finish highlights

* Remove entries that were part of previous releases

* Update PageBuilder to Page Builder

Co-authored-by: Devagouda <[email protected]>

* fix(pagebuilder): Html content type unescapes content when GraphQL does not (#2283)

Co-authored-by: Devagouda <[email protected]>

* [PWA-479] Extension Files Missing From Packages (#2305)

* Add extensible files and directories to published packages

* Revert version bumps

Co-authored-by: Devagouda <[email protected]>

* v6.0.0-beta.2

* [bug]: Fix (remove) OOTB tests from scaffold (#2321)

* Ignores buildpack and test directories during create-pwa

Signed-off-by: sirugh <[email protected]>

* Fix glob pattern to match sub directories AND contents

Signed-off-by: sirugh <[email protected]>

* Fixes tests and makes ignore pattern easier to construct

Signed-off-by: sirugh <[email protected]>

* [Doc] 6.0 release notes updates (#2323)

* Add new PRs to changelog and update compatibility table

* Fix wrong entry placement

* v6.0.0-beta.3

* v6.0.0-rc.1

* v6.0.0

* Enable cart and checkout routes

Co-authored-by: Revanth Kumar Annavarapu <[email protected]>
Co-authored-by: Tommy Wiebell <[email protected]>
Co-authored-by: Stephen <[email protected]>
Co-authored-by: devops-pwa-codebuild <[email protected]>
Co-authored-by: James Calcaben <[email protected]>
Co-authored-by: James Zetlen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:pagebuilder version: Patch This changeset includes backwards compatible bug fixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants