webmatch / WbmTagManager

Shopware 5 Plugin for Google Tag Manager integration and dataLayer configuration
27 stars 18 forks source link

Decode html special chars #8

Closed burhans2 closed 6 years ago

burhans2 commented 6 years ago

Strings containing quotation marks are currently html encoded For example, 15" screen is sent to GTM as 15" screen

dneustadt commented 6 years ago

Hello @burhans2 , thanks for your contribution. Instead of html entity decoding every string, I would recommend you prevent the encoding in the first place. To do so remove the smarty escape modifier from a value within the backend component of the plugin. On how to escape quotes only, please see the documentation of the smarty escape modifier @ https://www.smarty.net/docsv2/en/language.modifier.escape

burhans2 commented 6 years ago

Hi David,

thanks for your time and review as well. If the escaping is removed then json_decode part in method fillValues is failing. Because then we have an invalid json string like

{"name":"Article name with quote 15" article name continues", "id": "ArticleId"}

If you or others haven't had an issue with this before, maybe fixing it in the tag manager can be an option.

dneustadt commented 6 years ago

After further inspection the quotes option of the escape modifier seems to only escape single quotes. You could however, in addition to the escape modifier, use the replace modifier, to escape double quotes manually. {$sArticle.name|escape:'quotes'|replace:'"':'\"'} I realize this isn't the most elegant solution but it should do the job.

Since the "raw" json is compiled with smarty anyway, we'd like to ask users to do as many operations using smarty modifiers and functions as possible before actually hard-coding anything, that might not be in the interest for all users.

burhans2 commented 6 years ago

I understand the avoidance of hard-coding, especially if people are not having issues with this. Escape modifier was not helpful; however, replace modifier would work in my case. Thanks again.