X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   News and Announcements (https://forum.x-cart.com/forumdisplay.php?f=28)
-   -   X-Cart 4.7 beta:new skin, in-context checkout, custom order statuses, Smarty v3 (https://forum.x-cart.com/showthread.php?t=71550)

cflsystems 06-17-2015 04:36 AM

Re: X-Cart 4.7 beta:new skin, in-context checkout, custom order statuses, Smarty v3
 
Thank you

aim 06-17-2015 05:16 AM

Re: X-Cart 4.7 beta:new skin, in-context checkout, custom order statuses, Smarty v3
 
1 Attachment(s)
Quote:

Originally Posted by cflsystems
Am I missing something here or is this a bug in XC or Smarty 3

Smarty 3 eval fails if the text to evaluate has double quotes in it.

It took me some good time to find out why SmackDigital Dynamic Tabs module results in blank page, and XC static pages as well.

They all trying to eval text which looks like this for example

------------------------------------------
This is just a simple text using "quotes".
------------------------------------------

This will result in PHP Fatal error: Uncaught --> Smarty Compiler: Syntax error in template....

Replacing " with ' works but this should not happening in the first place. Using str_replace on the variable is my workaround for now but again this is ugly way of fixing the problem as it may show elsewhere as well.

QT - anything on this?



static_page_eval_quotes.diff has been uploaded.

smarty3 calls pre/post/output filters for the {eval} tag.

The recommended solution for custom pre/post/output filters is using a condition like this

Code:

function x_mc_remove_currency_options($tpl_source, $smarty)
 {
    if ('admin/main/configuration.tpl' == $smarty->template_resource) {
..........
        $tpl_source = some_func($tpl_source);
..........
    }

  return $tpl_source;
 }


cflsystems 06-17-2015 06:38 AM

Re: X-Cart 4.7 beta:new skin, in-context checkout, custom order statuses, Smarty v3
 
I don't understand what this has to do with the xAuth module. This module may or may not be included and may or may not be setup even if activated.

And I did install this patch just to prove it doesn't work.

aim 06-17-2015 10:21 PM

Re: X-Cart 4.7 beta:new skin, in-context checkout, custom order statuses, Smarty v3
 
Quote:

Originally Posted by cflsystems
I don't understand what this has to do with the xAuth module. This module may or may not be included and may or may not be setup even if activated.

And I did install this patch just to prove it doesn't work.


The original pre-filter was

Code:

function x_tpl_prefilter($source, &$smarty)
{
    return '{if $x_core_started}{xevent name="before" tpl="' . $smarty->template_resource . '"}{/if}'
        . $source
        . '{if $x_core_started}{xevent name="after" tpl="' . $smarty->template_resource . '"}{/if}';
}



The template for {eval} is
Code:

This is just a simple text using "quotes"


The resulted compiled template for {eval} was (which was wrong)
Code:


<?php if ($_smarty_tpl->tpl_vars['x_core_started']->value) {
echo x_tpl_fire_event(array('name'=>"before",'tpl'=>"eval:This is just a simple text using "quotes""),$_smarty_tpl);
}?>


This is just a simple text using "quotes"

<?php if ($_smarty_tpl->tpl_vars['x_core_started']->value) {
echo x_tpl_fire_event(array('name'=>"after",'tpl'=>"eval:This is just a simple text using "quotes""),$_smarty_tpl);
}?><?php }} ?>



This is unexpected behavior for the x_tpl_prefilter pre-filter

The expected compiled code is something like

Code:

<?php if ($_smarty_tpl->tpl_vars['x_core_started']->value) {
echo x_tpl_fire_event(array('name'=>"after",'tpl'=>"modules/Special_Offers/customer/new_offers_message.tpl"),$_smarty_tpl);
}?><?php }} ?>


aim 06-17-2015 10:24 PM

Re: X-Cart 4.7 beta:new skin, in-context checkout, custom order statuses, Smarty v3
 
The wrong php code is
Code:

echo x_tpl_fire_event(array('name'=>"before",'tpl'=>"eval:This is just a simple text using "quotes""),$_smarty_tpl);

cflsystems 06-18-2015 05:11 AM

Re: X-Cart 4.7 beta:new skin, in-context checkout, custom order statuses, Smarty v3
 
I am not sure I follow. The patch you provided static_page_eval_quotes.diff modifies xAuth module. This module is not in use, it is not setup and its code does nto run.
So how this solves the problem site wide or for static pages?

I installed the patch. Going to a static page results in same blank page with same error - because the patch you provided is not for static pages and it doesn't fix anything there.

aim 06-18-2015 05:19 AM

Re: X-Cart 4.7 beta:new skin, in-context checkout, custom order statuses, Smarty v3
 
Which modules do you use?
What is in your error logs?

cflsystems 06-18-2015 05:35 AM

Re: X-Cart 4.7 beta:new skin, in-context checkout, custom order statuses, Smarty v3
 
Forget modules. Stock XC. I can't show you this on the XC demo as it will not allow me to create/modify static page.
Create static page. Use double quotes in the text. Make sure " Parse Smarty tags in the content of embedded pages " option is active. Go to store fornt and try to access the static page. It results in the error I mentioned. This has nothing to do with any module. It is strictly the smarty {eval} and the value passed to it not being escaped.

If you use single quotes all works ok. If the " Parse Smarty tags in the content of embedded pages " option is not active all works ok. If the double quotes are replaced by their html coding all works ok.

aim 06-25-2015 10:59 PM

Re: X-Cart 4.7 beta:new skin, in-context checkout, custom order statuses, Smarty v3
 
Quote:

Originally Posted by cflsystems
Am I missing something here or is this a bug in XC or Smarty 3

Smarty 3 eval fails if the text to evaluate has double quotes in it.

It took me some good time to find out why SmackDigital Dynamic Tabs module results in blank page, and XC static pages as well.

They all trying to eval text which looks like this for example

------------------------------------------
This is just a simple text using "quotes".
------------------------------------------

This will result in PHP Fatal error: Uncaught --> Smarty Compiler: Syntax error in template....

Replacing " with ' works but this should not happening in the first place. Using str_replace on the variable is my workaround for now but again this is ugly way of fixing the problem as it may show elsewhere as well.

QT - anything on this?



https://forum.x-cart.com/showpost.php?p=388007&postcount=115

cflsystems 07-26-2015 09:54 PM

Re: X-Cart 4.7 beta:new skin, in-context checkout, custom order statuses, Smarty v3
 
Finding another issue with static pages and in general with the whole site - language variables.
Current store I am working on has about 8000 of them. On any given page only about 100 are being assigned to smarty and can be used in templates. None of the ones used in static pages from the old store work with the new one - they are just not in the $lng array.

Where is all this being assigned? Does it use some sort of cache? And how come only 100, give or take, are included in $lng array no matter which page is loaded?


All times are GMT -8. The time now is 12:40 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.