symfony / webpack-encore-bundle

Symfony integration with Webpack Encore!
https://symfony.com/webpack-encore
MIT License
938 stars 83 forks source link

Uncaught PHP Exception Twig\Error\RuntimeError: "An exception has been thrown during the rendering of a template ("Warning: htmlentities(): charset `' not supported, assuming utf-8")." #69

Open DraMaTiK opened 5 years ago

DraMaTiK commented 5 years ago

I am having troubles after installing webpack-encore-bundle with those two packages :

After setting up them, I am having this error message :

Uncaught PHP Exception Twig\Error\RuntimeError: "An exception has been thrown during the rendering of a template ("Warning: htmlentities(): charset `' not supported, assuming utf-8")."

The only one solution I found was to edit : vendor/symfony/webpack-encore-bundle/src/Asset/TagRenderer.php:L:149

Replace : return sprintf('%s="%s"', $key, htmlentities($value)); By this : return sprintf('%s="%s"', $key, htmlentities($value, ENT_QUOTES, 'utf-8'));

d4v1dm013 commented 4 years ago

I confirm this issue in webpack-encore-bundle 1.7.

This error appear randomly in dev environnement.

bcerati commented 4 years ago

Any news about this issue ?

I have the same error. How can you be so sure it is only in dev environment ?

androshchuk commented 4 years ago

So far I get such a problem only in a dev environment. For prod environment, everything works fine.

and for dev environment, I changed vendor/symfony/webpack-encore-bundle/src/Asset/TagRenderer.php:L:149 to

return sprintf('%s = "%s"', $key, htmlentities($value, ENT_COMPAT | ENT_XHTML, 'utf-8'));

Valen78 commented 3 years ago

Thanks for the solution, stil have the issue in webpack-encore-bundle 1.8.

Hope they will take this solution in next update because it's a lot ennoying !!

Kocal commented 3 years ago

Hi @Valen78, you are free to send a pull request if it's really annoying for you.