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

Product Cart cannot be displayed if Welcome Message contains single quotes #5003

Closed
bh-ref opened this issue Jun 13, 2016 · 5 comments
Closed
Labels
Area: Frontend bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release

Comments

@bh-ref
Copy link
Contributor

bh-ref commented Jun 13, 2016

Steps to reproduce

  1. Install Magento 2.1.0-rc2.
  2. Add a product to the cart.
  3. Switch to another language (storeview) which has a welcome message that contains a single quote. In my case, the default welcome message of my french storeview is Email d'accueil par défaut.

Expected result

  1. The same products can be seen in the cart when I click on the cart icon.

Actual result

  1. No products can be seen in the cart.
  2. Chrome dev tools show the following error message:
knockout.js:2624 Uncaught SyntaxError: Unable to process binding "ifnot: function (){return customer().fullname }"
Message: Unable to parse bindings.
Bindings value: html:'Email d'accueil par défaut'
Message: Unexpected identifiercreateBindingsStringEvaluator @ knockout.js:2624createBindingsStringEvaluatorViaCache @ knockout.js:2615ko.utils.extend.parseBindingsString @ knockout.js:2601ko.utils.extend.getBindingAccessors @ knockout.js:2583ko.dependentObservable.disposeWhenNodeIsRemoved @ knockout.js:2931evaluateImmediate @ knockout.js:1737ko.computed.ko.dependentObservable @ knockout.js:1946applyBindingsToNodeInternal @ knockout.js:2929applyBindingsToNodeAndDescendantsInternal @ knockout.js:2854applyBindingsToDescendantsInternal @ knockout.js:2836ko.applyBindingsToDescendants @ knockout.js:3052ko.computed.disposeWhenNodeIsRemoved @ knockout.js:4004evaluateImmediate @ knockout.js:1737ko.computed.ko.dependentObservable @ knockout.js:1946ko.bindingHandlers.(anonymous function).init @ knockout.js:3988(anonymous function) @ knockout.js:2989ko.computedContext.ko.dependencyDetection.ignore @ knockout.js:1249(anonymous function) @ knockout.js:2988ko.utils.arrayForEach @ knockout.js:151applyBindingsToNodeInternal @ knockout.js:2974applyBindingsToNodeAndDescendantsInternal @ knockout.js:2854applyBindingsToDescendantsInternal @ knockout.js:2836ko.applyBindingsToDescendants @ knockout.js:3052applyComponents @ scope.js:30Registry._resolveRequest @ registry.js:413Registry._updateRequests @ registry.js:395later @ underscore.js:821

To reproduce this error, you might as well go to app/code/MagentoTheme/view/frontend/templates/html/header.phtml and replace line 12 with this:

$welcomeMessage = "t'est";

and clean the cache and reload the page.

@cpartica cpartica added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report labels Jun 21, 2016
@cpartica
Copy link
Contributor

created internal issue MAGETWO-54590

@davidbilly
Copy link

davidbilly commented Jul 27, 2016

@bh-ref i have same issue : #5426 (comment)

This fixed after remove ' from welcome message. Thanks!

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Area: Frontend Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Sep 11, 2017
@magento-engcom-team magento-engcom-team added 2.1.x Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release labels Oct 17, 2017
@magento-engcom-team
Copy link
Contributor

@bh-ref, thank you for your report.
The issue is already fixed in develop branch, 2.2.0

@ChameleonDevil
Copy link

@bh-ref, thank you for your report.
The issue is already fixed in develop branch, 2.2.0

I don't think this was fixed completely. I have installed a new M2.3.5 installation where I have this same error - when trying to debug customer() at the knockout section of the header template at the welcome message it returns {} empty object.

I am getting the exact same error message as in issue #5426 which is related to this Welcome message.

#5426

Difference here is that I do not have products in this database yet. Can someone please point me to where customer() gets populated, I need to figure out why customer() is empty object at that point.

@ChameleonDevil
Copy link

ChameleonDevil commented Sep 30, 2020

Ok so this issue is related to how knockout seems to not correctly handle (') single quote characters in some theme templates.

If your template has this:

<!-- ko ifnot: customer().fullname -->
<span data-bind="html:'<?= $block->escapeHtml($welcomeMessage) ?>'"></>
<!-- /ko -->

Change to this:

<!-- ko ifnot: customer().fullname -->
<span data-bind='html:"<?= $block->escapeHtml($welcomeMessage) ?>"'></>
<!-- /ko -->

Notice I swapped the single quote and double quote positions such that the double quotes are inside, so that in effect does this:

' " ' " '
Instead of:
" ' ' ' "

I am positive anywhere (other templates) where knockout data-bind is used with PHP escapeHtml() or where quote characters are present will have this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release
Projects
None yet
Development

No branches or pull requests

6 participants