@mattab opened this Issue on April 9th 2014 Member

There is a data bug, where we give twig data in the wrong encoding and it errors out when calling htmlspecialchars.

URL where this was reproduced = index.php?date=2014-04-08&module=Actions&action=getPageUrls&idSite=1&period=day&search_recursive=1&viewDataTable=table&filter_sort_column=nb_visits&filter_sort_order=desc&idSubtable=11

Got this error:


Warning:htmlspecialchars(): Invalid multibyte sequence in argument in /mnt/storage/sites/piwik-21/docroot/vendor/twig/twig/lib/Twig/Extension/Core.php on line 968

Backtrace -->

<a href='/0'>#0</a> Piwik\Error::errorHandler(...) called at [:]
<a href='/1'>#1</a> htmlspecialchars(...) called at [/mnt/storage/sites/piwik-21/docroot/vendor/twig/twig/lib/Twig/Extension/Core.php:968]
<a href='/2'>#2</a> twig_escape_filter(...) called at [/mnt/piwik-tmp/piwik_piwik-21/rcart.piwik.pro/templates_c/c8/70/aa3e8e01e615d4ce1f1767b5894a5cd847edbaba00c73accef767a6c12b8.php:35]
<a href='/3'>#3</a> __TwigTemplate_c870aa3e8e01e615d4ce1f1767b5894a5cd847edbaba00c73accef767a6c12b8->doDisplay(...) called at [/mnt/storage/sites/piwik-21/docroot/vendor/twig/twig/lib/Twig/Template.php:276]
<a href='/4'>#4</a> Twig_Template->displayWithErrorHandling(...) called at [/mnt/storage/sites/piwik-21/docroot/vendor/twig/twig/lib/Twig/Template.php:250]
<a href='/5'>#5</a> Twig_Template->display(...) called at [/mnt/piwik-tmp/piwik_piwik-21/rcart.piwik.pro/templates_c/45/1a/eed9ac6aaeafc566968f6333c7f3a44d4f401ecf28d5ecb1f36cbc400e8d.php:119]
<a href='/6'>#6</a> __TwigTemplate_451aeed9ac6aaeafc566968f6333c7f3a44d4f401ecf28d5ecb1f36cbc400e8d->doDisplay(...) called at [/mnt/storage/sites/piwik-21/docroot/vendor/twig/twig/lib/Twig/Template.php:276]
<a href='/7'>#7</a> Twig_Template->displayWithErrorHandling(...) called at [/mnt/storage/sites/piwik-21/docroot/vendor/twig/twig/lib/Twig/Template.php:250]
<a href='/8'>#8</a> Twig_Template->display(...) called at [/mnt/piwik-tmp/piwik_piwik-21/rcart.piwik.pro/templates_c/89/ae/ae3a91d087ca0af778a2920d6eacd6c3d84ea46260b2d42c2ba7d664ff21.php:23]
<a href='/9'>#9</a> __TwigTemplate_89aeae3a91d087ca0af778a2920d6eacd6c3d84ea46260b2d42c2ba7d664ff21->doDisplay(...) called at [/mnt/storage/sites/piwik-21/docroot/vendor/twig/twig/lib/Twig/Template.php:276]
<a href='/10'>#10</a> Twig_Template->displayWithErrorHandling(...) called at [/mnt/storage/sites/piwik-21/docroot/vendor/twig/twig/lib/Twig/Template.php:250]
<a href='/11'>#11</a> Twig_Template->display(...) called at [/mnt/storage/sites/piwik-21/docroot/vendor/twig/twig/lib/Twig/Template.php:261]
<a href='/12'>#12</a> Twig_Template->render(...) called at [/mnt/storage/sites/piwik-21/docroot/vendor/twig/twig/lib/Twig/Environment.php:292]
<a href='/13'>#13</a> Twig_Environment->render(...) called at [/mnt/storage/sites/piwik-21/docroot/core/View.php:252]
<a href='/14'>#14</a> Piwik\View->renderTwigTemplate(...) called at [/mnt/storage/sites/piwik-21/docroot/core/View.php:247]
<a href='/15'>#15</a> Piwik\View->render(...) called at [/mnt/storage/sites/piwik-21/docroot/core/Plugin/ViewDataTable.php:359]
<a href='/16'>#16</a> Piwik\Plugin\ViewDataTable->render(...) called at [/mnt/storage/sites/piwik-21/docroot/core/Plugin/Controller.php:228]
<a href='/17'>#17</a> Piwik\Plugin\Controller->renderReport(...) called at [/mnt/storage/sites/piwik-21/docroot/plugins/Actions/Controller.php:89]
<a href='/18'>#18</a> Piwik\Plugins\Actions\Controller->getPageUrls(...) called at [:]
<a href='/19'>#19</a> call_user_func_array(...) called at [/mnt/storage/sites/piwik-21/docroot/core/FrontController.php:521]
<a href='/20'>#20</a> Piwik\FrontController->doDispatch(...) called at [/mnt/storage/sites/piwik-21/docroot/core/FrontController.php:84]
<a href='/21'>#21</a> Piwik\FrontController->dispatch(...) called at [/mnt/storage/sites/piwik-21/docroot/core/dispatch.php:30]
<a href='/22'>#22</a> require_once(...) called at [/mnt/storage/sites/piwik-21/docroot/index.php:47]

Solution:

  • fix the input data charset
  • or disable error reporting for the |escape filter
@mattab commented on April 10th 2014 Member

In 319cdf35076b90290ae729c7081ecea8695bd8bf: Refs #4974 Mark the URL as |raw so Twig does not apply the escaping which fails

@mattab commented on April 10th 2014 Member

Marking as fixed. If you experience this problem please comment here and re-open the ticket! thanks

@mattab commented on May 13th 2014 Member

Invalid multibyte sequence in argument in /html/piwik/vendor/twig/twig/lib/Twig/Extension/Core.php on line 927

This bug has occurred again in Piwik 2.2.2. I created ticket at #5157

This Issue was closed on May 13th 2014
Powered by GitHub Issue Mirror