简体   繁体   中英

Random bug with webpack-encore in symfony and encoding

I have a random problem with webpack-encore in symfony. When i refresh my page, i have an issue:

"An exception has been thrown during the rendering of a template ("Warning: htmlentities(): charset `throwAt' not supported, assuming utf-8")."

I refresh and i have:

"An exception has been thrown during the rendering of a template ("Warning: htmlentities(): charset `handler' not supported, assuming utf-8")."

I refresh and my page is good.

And it's a loop... (so weird !)

On others pages i don't see a loop. If i refresh, maybe work, maybe don't.

I have make some test. If i change this line in the TagRenderer.php (function: convertArrayToAttributes; line 114):

return sprintf('%s="%s"', $key, htmlentities($value));

with:

return sprintf('%s="%s"', $key, htmlentities($value, ENT_COMPAT | ENT_HTML401, "ISO8859-1"));

That work all the time. But I'm not sure that's the good solutions.

When i dump the "$value" before the line "htmlentities($value)", the value is: "stylesheet".

When i restart my computer, this issue disapear but with time, it's recome !

Do you have any idea?

For informations: I'm on a docker image. My source code are in UTF-8

Edit: Obviously, i clean the cache (via command or delete folder) before, after and between refresh but nothing change.

I myself drooled for two days to try to solve this problem. In fact this is where you make the text edit in CKEditor that poses this problem.

While testing different things, I realized that we need to add | raw, and in the convertArrayToAttributes method of the TagRenderer class, instead of:

return sprintf ('%s = "%s"', $key, htmlentities ($value));

rather do:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM